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.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
value |
unknown |
the value to keep instead |
Returns
Section titled “Returns”{ coerced: value }
Example
Section titled “Example”// a negative number of minutes becomes zerovalidate: value => (typeof value === 'number' && value < 0 ? coerced(0) : valid())