-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Some helpful validators #6
Comments
I don't particularly see the need for the I propose two additional functions though: Simple example:
|
I don't think ensureYield is general enough at first glance, but I like the idea of piping the value through a function. I'll play with it. Also, this.checkBody('uname').ensure(!(yield db.findUserByUname(this.request.body.uname)))
this.checkBody('uname').ensureNot(yield db.findUserByUname(this.request.body.uname)) // nicer Sure, not a big deal, but this library already has a precedent for |
yeah, very powerful! happy Chinese new year! |
Here are some validators I use in my project that I think should belong to koa-validate.
notMatch
- inverse ofmatch
ensure
- executes arbitrary expression. if falsey, then error. (koa-validate needs a generic validator for arbitrary expressions)ensureNot
(or perhapsrefute
) - inverse ofensure
Implementations:
edit: ignore shouldBail
The text was updated successfully, but these errors were encountered: