Skip to main content

never

$never

Inverts a processor - Returns the input if the wrapped processor throws or returns an undefined value. Throw a constraint error if the wrapped processor returns a defined value.

See $not to enforce falseyness.

Parameters

  • value (ProcessorSpec, required): The processor specification to negate (must not return a defined value).

Example

// Blacklist specific values — reject any input that is found in the lookup table
new Schema('string').validator({$never: {$lookup: {admin: true, root: true}}})

// Ensure a value does not parse as a number (must be a non-numeric string)
new Schema('string').validator({$never: '$numeric'})

// Reject any value that resolves from $get (path must NOT exist)
new Schema('object').validator({$never: {$get: 'deprecated.field'}})