Skip to content

coerced

function coerced(value): Coerced;

The answer of a facet check when the value is accepted, but another value is kept in its place. You return it from the validate function of ctx.facets.define.

Parameter Type Description
value unknown the value to keep instead

Coerced

{ coerced: value }

// a negative number of minutes becomes zero
validate: value => (typeof value === 'number' && value < 0 ? coerced(0) : valid())