question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Adding minlength and maxlength to Schema with String as type

See original GitHub issue

Add a new feature for minimum length and maximum length to Schema with String as type. This will validate minimum and maximum length to corresponding string in schema.

For example,

var s = new Schema({ name: { type: String, minlength: 5, maxlength: 15 }});

OR

var s = new Schema({ name: { type: String, min: 5, max: 15 }});

Issue Analytics

  • State:closed
  • Created 10 years ago
  • Comments:13

github_iconTop GitHub Comments

4reactions
jeremymlcommented, Aug 4, 2015

Here is the documentation for the new minlength validator http://mongoosejs.com/docs/api.html#schema_string_SchemaString-minlength

2reactions
aheckmanncommented, Apr 25, 2013

Not gonna happen. Mongoose is bloated enough and exposes the apis necessary to extend it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Possible to specify min/max length of a string in JSON schema ...
The length of a string can be constrained using the minLength and maxLength keywords. For both keywords, the value must be a non-negative ......
Read more >
String type | Opis JSON Schema
minLength. A string is valid against this keyword if its length is greater then, or equal to, the value of this keyword. Value...
Read more >
Mongoose v6.8.1: Validation
Strings have enum , match , minLength , and maxLength validators. ... Add a custom validator to all strings mongoose.Schema.Types.String.set('validate' ...
Read more >
string — Understanding JSON Schema 2020-12 documentation
The length of a string can be constrained using the minLength and maxLength keywords. For both keywords, the value must be a non-negative...
Read more >
Basic Types - JSON Schema
specifies that our JSON document is a string whose minimum length is 3 and whose maximum length is 7. The keywords "minLength" and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found