Chaining validators and sanitizers
See original GitHub issueInstead of this:
request.sanitize('developer').toInt()
request.sanitize('charity').toInt()
request.sanitize('email').trim()
request.sanitize('payform').trim()
request.sanitize('mixpanel_id').trim()
request.check('developer').isInt(min:0)
request.check('charity').optional().isInt(min:0)
request.check('email').trim().isEmail().isByteLength(0, 120)
request.check('payform').isByteLength(0, 120)
request.check('mixpanel_id').isByteLength(0, 120)
One could write this:
request.validator('developer').isInt(min:0).toInt()
request.validator('charity').optional().isInt(min:0).toInt()
request.validator('email').trim().isEmail().isByteLength(0, 120)
request.validator('payform').trim().isByteLength(0, 120)
request.validator('mixpanel_id').trim().isByteLength(0, 120)
Possible to implement this enhancement?
Issue Analytics
- State:
- Created 8 years ago
- Reactions:1
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Validation Chain API - express-validator
The validation chain is a middleware, and it should be passed to an Express route handler. You can add as many validators and...
Read more >Express-validator's default sanitizer doesn't work when chained
I am having trouble using the default() sanitizer from express-validator. When I use it in a chain, such as body("children").optional().
Read more >chain-validator-js - npm
Easy to integrate validator.js based validation with chain syntax, informative validation result, unwanted data cutting and sanitizing.
Read more >Chain order in schema · Issue #582 · express-validator ...
Is there a way to execute sanitizers and validators in the same order as they listed in schema? Here I have schema: const...
Read more >How to Use express-validator in Combination with Schema ...
Lastly, if you have to add some custom validations on top of this schema-based validation, then you can do that too. You can...
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
That could work. You would just need to account for name conflicts if someone accidentally creates a custom sanitizer/validator with the same name.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.