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.2 of the CertLogic specification.
Install from pub.dev
final data = {
'payload': payload, // Your DCC
'external': {
'valueSets': _valueSets, // The valuesets as provided by the EU GW
'validationClock': DateTime.now().toIso8601String(), // The validation time
},
};
CertLogic.evaluate(rule.logic, data) as bool
final failedRules = validationRules
?.map(
(rule) => CertLogic.evaluate(rule.logic, data) as bool == true ? null : rule,
)
.whereType<ValidationRule>()
.toList();
Executing the tests requires the test suite, located in a specification
folder, directly next to this directory.
dart test
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!