certlogic_dart 0.0.5
certlogic_dart: ^0.0.5 copied to clipboard

A package that can evaluate CertLogic

certlogic_dart #

pub package MIT license

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.1.0 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

Evaluate a single rule #

CertLogic.evaluate(rule.logic, data) as bool

Evaluate a list of rules and return all failed rules #

final failedRules = validationRules
        (rule) => CertLogic.evaluate(rule.logic, data) as bool == true ? null : rule,

Run tests #

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
152 succeeded and 0 failed
00:01 +17: All tests passed!
pub points



A package that can evaluate CertLogic

Repository (GitHub)
View/report issues


API reference




Packages that depend on certlogic_dart