SchemaType.checkRequired()

Parameters
  • fn «Function»
Returns:
  • «Function»

Override the function the required validator uses to check whether a value passes the required check. Override this on the individual SchemaType.

Example:

  1. // Use this to allow empty strings to pass the `required` validator
  2. mongoose.Schema.Types.String.checkRequired(v => typeof v === 'string');