express validator without express
See original GitHub issueexpress-validator is awesome, why just express!
I recently used express-validator in my express app and it was the best solution and now I am working on the front-end of that app with react. but I miss express-validator functionality in front-end for form validation.
I searched a lot on the net but I can’t find a way to implement it on my front-end is there a way? if there is no way so why keep this powerful thing on just express?
a separated library may be the solution
although I know that the express-validator uses validator.js under the hood but it can be very nice to have something like validation chains in the web apps something like :
import {createValidator} from 'the-name-for-separated-library'
const validator=createValidator([
check('some-field')
.exists()
.isEmail().withMessage('invalid email')
]);
const validationResult=validator.validate({
'some-field':'an invalid email'
});
if (!validationResult.isEmpty())
showToEndUserSomeHow(validationResult.array({onlyFirstError:true}))
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Running validations imperatively - express-validator
Running validations imperatively. express-validator favors the declarative way of doing things that express middlewares bring. This means most of the APIs look ...
Read more >A Clean Approach to Using Express Validator
I recently used express validator in a project and stumbled upon a few challenges which I'm going to share in this article.
Read more >Reusing validation rules without request · Issue #828 - GitHub
One possible solution is to actually rewrite the code (which I don't want to do) to just use validator package. In that case,...
Read more >How to use Express Validator | Getting Started with Express ...
Express -validator is an express middleware that provides us with validation and sanitization functions. Actually, Express validator is built on top of validator ......
Read more >How to validate request body in Node.js, Express
Express.js doesn't have a built-in validator. But you can use express-validator or joi. Both of these libraries are good.
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
If were familiar with how express middlewares run, you can reuse those APIs without changes in express-validator. I will show the main process and you can wrap them as a function as you wish. Not tested but should able to work.
Closing this /cc @gustavohenke