Closed whatyouhide closed 4 years ago
Sounds good to me but I think :one_of
would be a better name?
@josevalim I wanted to keep one_of
for the possibility of compound types later on (such as {:one_of, [:integer, :string, :atom]}
. Thoughts?
@whatyouhide I would say that is a :union
. :)
@josevalim fair enough, I'll make a PR for :one_of
then.
I like this proposal. Should this support a list or more generally any enumerable?
Btw, when I was evaluating libraries like Saul and Norm I arrived at the following list of operations that seemed useful
:symmetric_difference doesn't quite has the same ring to it as the other two but it is by far less common :)
In our case, since we don’t generate, I think only one_of is possible?
This brings up the reason why I wanted to call it :member
. Membership is about: is this value in this list (or set potentially)? The elements of the list are simple elements, not other validators. It's easy to implement and use. Thoughts?
I would use one_of for values and union/intersection for types. Member sounds weird for some reason. ::
A pretty common possible option value is a member of a list. An example that comes to mind is Broadway's
:batch_mode
inBroadway.test_messages/3
, which is:bulk
or:flush
.Do we want to support a "member" type?
Do you think it's too soon, too specific, or a good addition?