Express Array Validator fails when the array size increases 1000
See original GitHub issueThe express validator fails to read and validate elements of array if the array size increases 1000. We are validating the array elements as follows
body('ids).optional().isArray(),
body('ids.*').not().isEmpty().withMessage('Required')
.trim().isAlphanumeric().withMessage('Alpha Numeric')
.isLength({ min: 1, max: 10 }).withMessage('Max 10 Characters'),
Where ids would be an array like [‘T0001’,‘T0002’,‘T0003’,…,‘T1100’]. So now this array contains 1100 elements. But if we reduce the size of elements to 500 or 600 the above validation works perfectly. Is there a different way to validate array of large size?
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:9 (5 by maintainers)
Top Results From Across the Web
Validation for array returns error for only 1st item and ignores ...
Hi, I am using schema-validation with express-validator 4.3.0, using a jsonSchema.json file. Within the schema, there is an array of objects ...
Read more >express-validator to validate parameter which is an array
If you are using express-validator, You can pass minimum / maximum length option to check whether Array is empty or exceeds a certain...
Read more >17.7.0 API Reference - joi.dev
Validates a value against a schema and throws if validation fails where: ... length(item) - reutrn the length of an array or string,...
Read more >Active Record Validations - Ruby on Rails Guides
Active Record ValidationsThis guide teaches you how to validate the state of objects ... It returns an array of all the error messages...
Read more >5.x API - Express.js
toString() may fail in multiple ways, for example foo may not be there or may not be a ... This option can be...
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 Free
Top 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
@liqiang372 Thanks for your suggestions. Your direction pointed me in the right direction.
I think I have narrowed down the issue. Ref: stackoverflow.com/q/19917401 Ref: https://expressjs.com/en/4x/api.html#express.json
Just be setting
express.json({limit:'3mb'})
fixed the issue which I was facing. Will be releasing the API in production server on weekend. Will update it here once I also test this in the production server.Setting express json config resolved the issue