-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Split except into a separate validator and allow both to accept either check or list Procs #1616
Comments
This looks great to me. It could also make it into 1.0 easily if you need to make it a breaking change. |
I think we might want to use a different name for the new validator. There's already an
Perhaps @dblock Thoughts? |
I think |
Deprecate except and proc options of values validator. Values validator now distinguishes between arity zero and arity one Procs. Check default(s) against the except_values list. Handle case where default is an array and values / except_values are ranges.
Deprecate except and proc options of values validator. Values validator now distinguishes between arity zero and arity one Procs. Check default(s) against the except_values list. Handle case where default is an array and values / except_values are ranges.
Deprecate except and proc options of values validator. Values validator now distinguishes between arity zero and arity one Procs. Check default(s) against the except_values list. Handle case where default is an array and values / except_values are ranges.
Deprecate except and proc options of values validator. Values validator now distinguishes between arity zero and arity one Procs. Check default(s) against the except_values list. Handle case where default is an array and values / except_values are ranges.
Feature #1616 - split out except_values validator
With #1616 merged, I think this can be closed. |
I'm not in love with the complexity of the
values:
validator (even though I contributed to some of it!) I think it would be cleaner to split out theexcept:
functionality into its own separate top-level validator. In addition, I'd like forvalues:
to take two different kinds of Proc -- the first, with an arity of zero, would simply return a dynamically calculated list of valid (or excluded) values. That's how it works today.If, however, the arity of the supplied Proc is one, the param value in question would would be passed in and the Proc would be expected to return true or false. That's how the
proc
option of the values validator works today.Some examples:
Current
Proposed
I don't see any reason to allow arity one Procs with the
except_values:
validator since one could just use the values validator to do the same thing.What I like about this proposal is that it restores
values:
to the old pattern of only needing a Hash if a custom message is to be used when it fails. And the newexcept_values:
validator follows the same pattern.I'm happy to do this work, but I wanted to solicit opinions before starting. If the concept is deemed sound, we'd also want to determine whether to replace or deprecate the existing functionality. Normally I'd say deprecate, but as we're looking at a major release, perhaps we don't need to?
The text was updated successfully, but these errors were encountered: