Skip to content

FacetOwner

Additional validation that a plugin applies to the values of a facet. The app first checks a value against the schema of the facet, and then calls validate for the rules that a schema cannot express, such as a relationship between two fields.

ctx.facets.define(minutes, {
validate: value => (typeof value === 'number' && value >= 0 ? valid() : invalid({ code: 'minutes', message: 'Minutes must be zero or more' })),
});
readonly validate?: (value) => ValueVerdict;

Called for a value that already conforms to the schema.

Parameter Type Description
value unknown the value to check

ValueVerdict

valid() to accept the value, coerced(value) to keep another value in its place, or invalid({ code, message }) to refuse it