This library was generated with Nx.
This library consists of a set of predicate functions that check whether
an input satisfies a given constraint. These are leveraged for validation by our
@coscrad/data-types
library by registering constraints for each data-type.
This library is also used for client-side form validation. We send the constraints
for a field "over the wire" and then validate against said constraints via the
helper isConstraintSatisfied
.
Given a CoscradConstraint
and an input
value, determine if the input
satisfies
the constraint via a call to:
isConstraintSatisfied(
constraintName: CoscradConstraint,
value: unknown
)
To add a new constraint foo
, first register this in the enum CoscradConstraint
in coscrad-constraint.enum.ts
.
Then add a test is-foo.spec.ts
(see existing tests for the format)
and the corresponding predicate function is-foo.ts
. Finally, register your constraint by
its name in the constraintsLookupTable
in is-constraint-satisfied
.
Run nx test validation-constraints
to execute the unit tests via Jest.
Run nx lint validation-constraints
to execute the lint via ESLint.