Skip to content

l.bool()

Passes when the value is a bool. Returns a BoolValidator<bool?>. Strings such as 'true' fail. To require true rather than any bool, add a custom validator.

BoolValidator<bool?> bool({String? message, MessageBuilder? messageBuilder})
Parameter Type Meaning
message String? Replaces the default error message.
messageBuilder MessageBuilder? Builds the message from the issue. message wins when both are given. See Message builders.

Code invalidType. Default message: value must be a bool. value is replaced by the field name when there is one.

A bool parameter maps to l.bool().

final flag = l.bool();
flag.validate(input)+2-1
  1. valid: true
  2. valid: false
  3. invalid: 'true'value must be a bool