Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/schema/string.js
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ SchemaString.prototype.trim = function(shouldTrim) {
*
* #### Example:
*
* const schema = new Schema({ postalCode: { type: String, minlength: 5 })
* const schema = new Schema({ postalCode: { type: String, minLength: 5 })
* const Address = db.model('Address', schema)
* const address = new Address({ postalCode: '9512' })
* address.save(function (err) {
Expand All @@ -392,8 +392,8 @@ SchemaString.prototype.trim = function(shouldTrim) {
*
* // custom error messages
* // We can also use the special {MINLENGTH} token which will be replaced with the minimum allowed length
* const minlength = [5, 'The value of path `{PATH}` (`{VALUE}`) is shorter than the minimum allowed length ({MINLENGTH}).'];
* const schema = new Schema({ postalCode: { type: String, minlength: minlength })
* const minLength = [5, 'The value of path `{PATH}` (`{VALUE}`) is shorter than the minimum allowed length ({MINLENGTH}).'];
* const schema = new Schema({ postalCode: { type: String, minLength: minLength })
* const Address = mongoose.model('Address', schema);
* const address = new Address({ postalCode: '9512' });
* address.validate(function (err) {
Expand Down
2 changes: 2 additions & 0 deletions types/schematypes.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,11 @@ declare module 'mongoose' {

/** If set, Mongoose will add a custom validator that ensures the given string's `length` is at least the given number. */
minlength?: number | [number, string] | readonly [number, string];
minLength?: number | [number, string] | readonly [number, string];

/** If set, Mongoose will add a custom validator that ensures the given string's `length` is at most the given number. */
maxlength?: number | [number, string] | readonly [number, string];
maxLength?: number | [number, string] | readonly [number, string];

[other: string]: any;

Expand Down