Adding minlength and maxlength to Schema with String as type
See original GitHub issueAdd 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:
- Created 10 years ago
- Comments:13
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Here is the documentation for the new
minlength
validator http://mongoosejs.com/docs/api.html#schema_string_SchemaString-minlengthNot gonna happen. Mongoose is bloated enough and exposes the apis necessary to extend it.