InList<T extends Enum> class
Validates that the value matches an entry from an enum list.
Accepts either the enum instance itself or a wire string. By default the
wire string is compared to Enum.name. Supply a wire mapper to customize
the wire representation (e.g. snake_case), or caseInsensitive to ignore
case.
enum Severity { low, medium, high }
Validator.make({'severity': 'high'}, {
'severity': [InList(Severity.values)],
});
Properties
- caseInsensitive → bool
-
Whether string comparison ignores case.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
values
→ List<
T> -
The allowed enum values (immutable snapshot of the caller-provided list).
final
- wire → String Function(T value)?
-
Optional mapper to translate an enum to its wire representation.
final
Methods
-
message(
) → String -
Get the validation error message.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
params(
) → Map< String, dynamic> -
Get the replacement parameters for the message.
override
-
passes(
String attribute, dynamic value, Map< String, dynamic> data) → bool -
Determine if the validation rule passes.
override
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited