StartWithValidator class

A validator that checks if the value starts with start.

The StartWithValidator can be used with FieldControllers holding values of type String. It ensures that the value starts with start.

If the value is null it is treated as valid by default.

Properties

  • start: The value that the field should start with.
  • message: An optional custom error message to display when invalid.

Example

FieldController<String> field = FieldController(
  key: 'string',
  validators:[StartWithValidator('hello')],
);

// If field.value = 'world, hello!', validation fails.
// If field.value = 'hello world!', validation passes.

See also

Inheritance

Constructors

StartWithValidator.new(String start, {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
start String
The value that the field should start with.
final

Methods

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

Operators

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