-
-
Notifications
You must be signed in to change notification settings - Fork 110
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
Possibility to validate in relation to other rules #164
Comments
Hey @Buzut, thank you for your really good question. Actually, I believe it's possible to implement this feature in some way, and it's something really interesting to do. But we'll probably have to introduce some kind of abstraction in the middle of the What kind of ideas do you have for us to achieve that? |
Thank you for your interest in my question. So to keep the whole library coherent, I'd see something that works in the same way as const validation = v8n().schema({
id: v8n()
.number()
.positive(),
name: v8n()
.string()
.minLength(4),
isMarried: v8n()
.boolean(),
birthname: v8n() // this one would be required only if isMarried is true
.string()
.minLength(4)
.optionalIf(v8n().schema('isMarried').exact(true))
}); Or if having a polymorphic |
I think the above would be good style. It seems a bit difficult to implement, but definitely something to look at in my opinion.The main difficulty comes from |
Thank you very much for this incredible validation library. It's so lightweight and flexible, I use it everywhere and even created a Node.js API validation module on top of it.
I know v8n doesn't aim to mimic Joi, but it also has the ability to validate schemas. Would it be possible to have conditional validation at some point, like XOR, NAND etc?
Let me illustrate this:
The text was updated successfully, but these errors were encountered: