and performs the equivalent of a logical 'and' between two preconditions.
caseOf allows for the selective application of a precondition based on the type or structure of the value.
Pattern matching works as follows: string -> Matches on the value of the string. number -> Matches on the value of the number. boolean -> Matches on the value of the boolean. object -> Each key of the object is matched on the value, all must match. function -> Treated as a constructor and results in an instanceof check. For String,Number and Boolean, this uses the typeof check.
constant forces the value to be the supplied value.
discard throws away a value by assigning it ot undefined.
eq tests if the value is equal (strictly) to the target.
every takes a set of preconditions and attempts to apply each one after the other to the input.
exists requires the value to be enumerated in the supplied list.
identity always succeeds with the value it is applied to.
isin requires the value passed to be a member of a provided list.
log the value to the console.
match preforms a type/structure matching on the input value in order to decide which precondition to apply.
Preconditions must be wrapped in a 'caseOf' precondition.
neq tests if the value is not equal (strictly) to the target.
notNull will fail if the value is null or undefined.
optional applies the precondition given only if the value is not null or undefined.
or performs the equivalent of a logical 'or' between two preconditions.
reject always fails with reason no matter the value supplied.
when conditionally applies one of two preconditions depending on the outcome of a test function.
whenFalse (opposite of whenTrue).
whenTrue conditionally applies "applied" or "otherwise" depending on whether "condition" is true or not.
Generated using TypeDoc
Precondition represents some condition that must be satisfied in order for data to be considered a valid type.
A Precondition accepts a value of type and returns an Either where the left side contains information about why the precondition failed or the right the resulting type and value.