Accepted class

The Accepted Rule.

Validates that the field was "accepted" - useful for terms of service, agreement checkboxes, and similar boolean confirmations.

Usage

validate({
  'terms': true,
  'newsletter': 'yes',
}, {
  'terms': [Accepted()],
});

Accepted Values

The following values are considered "accepted":

  • true (boolean)
  • 1 (int)
  • "1" (string)
  • "yes" (case-insensitive)
  • "on" (case-insensitive)
  • "true" (case-insensitive)
Inheritance

Constructors

Accepted()
Creates an Accepted rule. Const, because it carries no state.
const

Properties

hashCode int
The hash code for this object.
no setterinherited
name String
The short name this rule is known by in a messages override map.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

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.
inherited
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