question: Express Request Object In Custom Validator
See original GitHub issueHow do I get the express request object in a custom validator?
@ValidatorConstraint()
class IsPublic implements ValidatorConstraintInterface {
validate(isPublic: boolean, args: ValidationArguments) {
// I want to use the request object here
return true;
}
defaultMessage(args: ValidationArguments) {
return "You don't have the right to create a public group";
}
}
Issue Analytics
- State:
- Created 4 years ago
- Reactions:11
- Comments:6 (2 by maintainers)
Top Results From Across the Web
How to access request object when defining validators as a ...
Hi, I have a use case where I want to load a different set of validators based on the parameter from the URL....
Read more >Custom validator on object in express-validation
Okay, so there are few problems with your script: Within the custom handler, you are iterating using forEach : Object.keys(value).
Read more >How to handle request validation in your Express API
You can validate any property in the Express request object, such as query , which contains the URL query string parsed into an...
Read more >How to perform custom validation in your Express.js app ...
What you can achieve with custom validation · Check if the entity exists in your database · Verify against certain values in Array...
Read more >Custom validators/sanitizers - express-validator
A custom validator may be implemented by using the chain method .custom() . It takes a validator function. Custom validators may return Promises...
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
Right now we do not have option to pass additional context (like request object) into validation process.
i need it too