.contains()
Passes when value.contains(substring) is true. Case-sensitive.
Signature
Section titled “Signature”StringValidator<O> contains(String substring, {String? message, MessageBuilder? messageBuilder})Parameters
Section titled “Parameters”| Parameter | Type | Meaning |
|---|---|---|
substring |
String |
The text that has to appear. params['substring']. |
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 missingSubstring. Default message: value does not contain "@". value is replaced by the field name when there is one.
Code generation
Section titled “Code generation”@Contains(s). Put the annotation on the constructor parameter or the field.
Example
Section titled “Example”final handle = l.string().contains('@');@Contains('@') required String handle, // l.string().contains("@").required()handle.validate(input)+1-1- valid:
'[email protected]' - invalid:
'a'