FindingLeveltypeno test imports ittype FindingLevel = "syntax" | "schema" | "profile" | "terminology" | "business-rule";Where a finding was found.
Schema and Profile as typed constraints over the abstract tree, and validation (commons integrations 0006-integrations-exchange): a schema says which paths a transaction has and how many times, a profile adds constraints to a schema, a terminology says which codes a binding allows, and validation gives findings at the level where each was found (syntax, schema, profile, terminology, business rule).
A finding has a level, a severity, a path, a code and a message made of the code and the path: it never holds a value of the payload, so that findings may be logged (commons integrations 0003-integrations-logical FR-003). A business rule is a function of the tree that returns findings, supplied by an agreement.
FindingLeveltypeno test imports ittype FindingLevel = "syntax" | "schema" | "profile" | "terminology" | "business-rule";Where a finding was found.
Severitytypeno test imports ittype Severity = "error" | "warning" | "information";How bad a finding is.
FindingCodetypeno test imports ittype FindingCode =
| "syntax-error"
| "unknown-path"
| "cardinality-min"
| "cardinality-max"
| "value-pattern"
| "value-fixed"
| "code-not-in-terminology"
| "terminology-unavailable"
| "business-rule"
| "unmapped-source-field"
| "lossy-mapping"
| "mapping-target-conflict";What a finding says.
FINDING_CODESconstconst FINDING_CODES: readonly FindingCode[]Every finding code, as a closed list of strings a consumer may carry as data; the compiler holds it complete against FindingCode.
FINDING_LEVELSconstconst FINDING_LEVELS: readonly FindingLevel[]Every level of a finding.
Findingtypeno test imports ittype Finding = { readonly level: FindingLevel; readonly severity: Severity; readonly code: FindingCode; readonly path: string; readonly message: string };A finding: never a value of the payload.
findingconstconst finding: (level: FindingLevel, severity: Severity, code: FindingCode, path: string, note?: string) => FindingA finding from its parts, its message made of the code and the path.
Constrainttypetype Constraint =
| { readonly kind: "cardinality"; readonly path: string; readonly min: number; readonly max: number … (567 characters)type Constraint =
| { readonly kind: "cardinality"; readonly path: string; readonly min: number; readonly max: number | "*" }
| { readonly kind: "choice"; readonly path: string; readonly alternatives: readonly string[]; readonly min: number; readonly max: number | "*" }
| { readonly kind: "pattern"; readonly path: string; readonly regex: string }
| { readonly kind: "fixed"; readonly path: string; readonly value: string }
| { readonly kind: "binding"; readonly path: string; readonly terminology: Ref<"terminology">; readonly strength: BindingStrength };What a path of a schema must be.
Schematypetype Schema = { readonly id: Ref<"schema">; readonly transaction: string; readonly paths: readonly string[]; readonly constraints: readonly Constraint[] };A schema: the paths a kind of transaction has, with their constraints. A path with no constraint is allowed; a path not listed (and not below a listed one) is unknown.
Profiletypeno test imports ittype Profile = { readonly id: Ref<"profile">; readonly schema: Ref<"schema">; readonly constraints: readonly Constraint[] };A profile: more constraints on a schema.
Terminologytypetype Terminology = { readonly id: Ref<"terminology">; readonly codes: ReadonlySet<string> };A code system or value set, as the codes it holds. Loaded from data the user supplies or the issuer publishes; the library embeds none.
Terminologiestypeno test imports ittype Terminologies = ReadonlyMap<StandardUrn, Terminology>;Terminologies by urn.
BusinessRuletypeno test imports ittype BusinessRule = (t: Transaction) => readonly Finding[];A rule of business: a function of a transaction that gives findings (never of values).
validatefunctionfunction validate(t: Transaction, schema: Schema, options?: { readonly profile?: Profile | undefined; readonly terminologies?: Terminologies | undefined; readonly rules?: readonly BusinessRule[] | undefined; }): readonly Finding[]Every finding of a transaction against a schema, a profile where given, the terminologies loaded, and the rules of business supplied, in that order of level. Total and pure.
hasErrorsconstconst hasErrors: (fs: readonly Finding[]) => booleanWhether the findings hold an error.
Checkedtypeno test imports ittype Checked<T> = Result<T, readonly Finding[]>;A result of a step that may give findings: the value, or the findings that stopped it.