-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Make certain rules override themselves #1127
Comments
I think this is where "prototyping" your schema carefully can negate this potentially-messy feature. const baseArray = Joi.array();
const min1 = baseArray.min(1);
const min0 = baseArray.min(0); I know that's more to keep up, but if you're using a library of schemas I don't think this would increase your maintenance overhead too much more. |
This is not completely far fetched, since a few rules already do that. Indeed better designing your schemas is a solution but I'm not against supporting this. |
Alright, we can let it sit here for a while to see if more people want this, and I can later try to issue a PR if it won't turn out crazy complex. Meanwhile, do the following examples fall under this request, or should it be considered a bug?
Both of which allow unknown (I'm aware that's the behavior of I.e. it easily allows to create unintended consequences that could become security issues. |
Options are transmitted down while flags are local, flags should probably always win so there's nothing to fix here. I'd limit the scope of this PR to what's local. |
This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions. |
Context
10.2.2
What are you trying to achieve or the steps to reproduce ?
Currently, calling e.g.
.min()
multiple times just accumulates the rules (as it should), but in this case it doesn't make sense.Suppose I have a library of schemas, and the default for some array is
.min(1)
.. if I want to re-use the schema but override it to allow0
members, I can't AFAIK.should IMO override the
0
with1
.I understand that for some rules it'd be hard to determine what should override what -- particularly when trying to override one rule with a different one (e.g.
min(1).allow([])
), but I think that it might not be hard to specify a list of rules which override themselves (min
,max
etc.).Thoughts?
The text was updated successfully, but these errors were encountered: