EnumValidator<T> class

Validates that a value is one of the allowed values.

Also contributes enum: [...] to the OpenAPI schema via toSchemaProperties.

Field<String>(validators: [EnumValidator(['draft', 'published', 'archived'])])
Field<int>(validators: [EnumValidator([1, 2, 3])])
Inheritance

Constructors

EnumValidator(List<T> values, [String? message])

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
validationErrorMessage String
The error message to show if validation fails.
finalinherited
values List<T>
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toSchemaProperties() Map<String, dynamic>
Returns OpenAPI-compatible JSON Schema constraints contributed by this validator (e.g. {'minLength': 8}, {'format': 'email'}).
override
toString() String
A string representation of this object.
inherited
validate(dynamic value) bool
Validates the provided value.
override

Operators

operator ==(Object other) bool
The equality operator.
inherited