Predefined valiation rules
Valid if a type of value is that specified by param.
value
param
null|boolean|boolean?|integer|integer?|number|number?|string|object|object?|array|array?
value to validate
Valid if value is either of values in param. Comparison is executed with ===.
===
candidates
Valid if value is === to param.
const
Valid if value is not a empty string. If value is not a string, then valid.
Valid if value of Object has all properties specifed by param. If value is not an Object, then valid.
a list of property names
Valid if value of Object is an instance of a tagged union specified by param
param = { tagProperty: "tag", types: { leafOf: ["value"], nodeOf: ["left", "right"] }}switchRequired of `{tag:"leafOf", value:1}` evaludates valid.switchRequired of `{tag:"nodeOf", left:otherNode}` evaluates invalid since `right` property is missing.
We can use tagged unions by using the switchRequired rule. But notice, even if the property sets are different, if the property names are the same, the schema will be the same.
Valid if value is strictly equals to a value located in a path specified by param.
path to the value to be compared
Valid if either of:
Valid if value, where it is a number, is multiple of param.
Generated using TypeDoc
Predefined valiation rules