require
$require
Require that the provided processor returns a defined value; return the original input if so. Throws a constraint error if the processor does not return a defined value.
May be used inline in a pipeline without parameters, or can have a single processor argument.
Parameters
processor(ProcessorSpec, optional): Processor specification to check for a defined return value. If omitted, the input value itself is checked for defined-ness.
Example
// Require the input to be defined (not undefined)
new Schema('any').validator('$require')
// Require a lookup to succeed (key must exist in the table)
new Schema('string').validator({
$require: {$lookup: {$literal: {admin: 1, user: 2, guest: 3}}}
})
// Require a nested path to resolve
new Schema('object').validator({$require: {$get: 'metadata.version'}})