-
Notifications
You must be signed in to change notification settings - Fork 84
Description
In(params T[])
This type of validator would accept a sequence of values (the sequence). The implementation would scan the sequence and throw an exception if any element in the sequence evaluates to the value represented by the validator.
NotIn(params T[])
This type of validator would accept a sequence of values (the sequence). The implementation would scan the sequence and throw an exception if no element in the sequence evaluates to the value represented by the validator.
Justification:
This eliminates the need for verbose checks such as x == 1 || x == 3 || x == 17 || x == 21
and reduces them to x.In(1, 3, 17, 21)
, while x.NotIn(1, 3, 17, 21)
is the natural reduction of x != 1 && x != 3 && x != 17 && x != 21
.
This type of validation is appropriate for all comparable types (string
, and all the numeric data types) and all Enum
types.