-
Notifications
You must be signed in to change notification settings - Fork 935
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
fix: concat of required() for array/string #459
Conversation
I like this approach (along with the consolidated skip absent option) because it gets us halfway to solving another issue around allowing empty strings as empty values to be configurable. However I don't think this fixes the real problem here, just avoids it. Extending and overriding schema is supported and concat should still work in those cases. |
|
Schema are structured as classes explicitly to allow this sort of thing, the documentation on extending schema also actively includes overriding a base method, that it's not a test shouldn't matter. So yes it's definitely fixing the bug by avoiding the problem. I don't necessarily think that's a bad thing in this instance but i don't think it's worth trying to frame it differently. |
All examples are about adding new I see no easy way to support overriding any method. We have around four categories of methods for this:
So, category number 4 is supported, but first three are not. One way to support them is to add invocation tracking for those methods and in It still will require writing such system, it will not be simple as just extending class as you will need to register such methods and |
sorry I'm not actually convinced the behavior you're describing above is a bug. mixed().required().concat(array().required()).isValid([]) // false
mixed().required().concat(array())).isValid([]) // true
mixed().required().concat(array())).isValid(undefined) // false The above is what I'd expect when merging instances of different types together, you aren't going to get the more restrictive check if the more restrictive type doesn't contain that check. I wouldn't expect the |
Some thoughts and points for single "you aren't going to get the more restrictive check" - only other check which is type dependent is type check itself, and it gets more restrictive.
If Handling double presence of Overall, i think having multiply variants of (I think if it was named |
Number 1 from #454
Removed redefinition of
required()
fromarray
andstring
, instead added_isFilled(value)
method for subtypes to override. Redefinition ofrequired()
causes problems withconcat
: