SchemaStringOptions


SchemaStringOptions()

Type:
  • «constructor»
Inherits:

The options defined on a string schematype.

Example:

const schema = new Schema({ name: String });
schema.path('name').options; // SchemaStringOptions instance

SchemaStringOptions.prototype.enum

Type:
  • «Array»

Array of allowed values for this path


SchemaStringOptions.prototype.lowercase

Type:
  • «Boolean»

If truthy, Mongoose will add a custom setter that lowercases this string using JavaScript's built-in String#toLowerCase().


SchemaStringOptions.prototype.match

Type:
  • «RegExp»

Attach a validator that succeeds if the data string matches the given regular expression, and fails otherwise.


SchemaStringOptions.prototype.maxLength

Type:
  • «Number»

If set, Mongoose will add a custom validator that ensures the given string's length is at most the given number.

Mongoose supports two different spellings for this option: maxLength and maxlength. maxLength is the recommended way to specify this option, but Mongoose also supports maxlength (lowercase "l").


SchemaStringOptions.prototype.minLength

Type:
  • «Number»

If set, Mongoose will add a custom validator that ensures the given string's length is at least the given number.

Mongoose supports two different spellings for this option: minLength and minlength. minLength is the recommended way to specify this option, but Mongoose also supports minlength (lowercase "l").


SchemaStringOptions.prototype.populate

Type:
  • «Object»

Sets default populate options.


SchemaStringOptions.prototype.trim

Type:
  • «Boolean»

If truthy, Mongoose will add a custom setter that removes leading and trailing whitespace using JavaScript's built-in String#trim().


SchemaStringOptions.prototype.uppercase

Type:
  • «Boolean»

If truthy, Mongoose will add a custom setter that uppercases this string using JavaScript's built-in String#toUpperCase().