0 purchases
certlogic dart
certlogic_dart #
CertLogic is a standard for expressing logic, such as the kind you find in business/validation rules, in plain JSON format.
It is a specified subset of JsonLogic, extended with necessary custom operations - e.g. for working with dates.
It's part of the efforts surrounding the Digital COVID Certificate, and as such serves as the basis for defining interchangeable validation rules on top of the DCC.
This Dart package consists of an implementation of CertLogic in Dart(/Flutter), compatible with version 1.3.1 of the CertLogic specification.
Install #
Install from pub.dev
Example for dgc-business-rules #
Prepare your data #
final data = {
'payload': payload, // Your DCC
'external': {
'valueSets': _valueSets, // The valuesets as provided by the EU GW
'validationClock': DateTime.now().toIso8601String(), // The validation time
},
};
copied to clipboard
Evaluate a single rule #
CertLogic.evaluate(rule.logic, data) as bool
copied to clipboard
Evaluate a list of rules and return all failed rules #
final failedRules = validationRules
?.map(
(rule) => CertLogic.evaluate(rule.logic, data) as bool == true ? null : rule,
)
.whereType<ValidationRule>()
.toList();
copied to clipboard
Run tests #
Executing the tests requires the test suite, located in a specification folder, directly next to this directory.
dart test
copied to clipboard
The output should be as follows:
00:01 +16: test/test_suite_test.dart: validate test suite
181 succeeded and 0 failed
00:01 +17: All tests passed!
copied to clipboard
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.