IsRequired<T> class

A validator that checks if the value is not null, empty nor false.

The IsRequired can be used with FieldControllers holding values of types String, Iterable, Map or bool. It ensures that the value is not null, empty nor false.

Properties

  • message: An optional custom error message to display when invalid.

Example

FieldController<String> field = FieldController(
  key: 'name',
  validators:[IsRequired()],
);

// If field.value = null, validation fails.
// If field.value = '', validation fails.
// If field.value = 'Ana', validation passes.

See also

Inheritance

Constructors

IsRequired.new({String? message})

Properties

hashCode int
The hash code for this object.
no setterinherited
message String?
finalinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

call(FieldController<T> controller) ValidationResult
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
onValidate(FieldController controller) ValidationResult
override
toString() String
A string representation of this object.
inherited

Operators

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