.startsWith()
Passes when value.startsWith(prefix) is true. Case-sensitive.
Signature
Section titled “Signature”StringValidator<O> startsWith(String prefix, {String? message, MessageBuilder? messageBuilder})Parameters
Section titled “Parameters”| Parameter | Type | Meaning |
|---|---|---|
prefix |
String |
The required prefix. params['prefix']. |
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 missingPrefix. Default message: value does not start with "+". value is replaced by the field name when there is one.
Code generation
Section titled “Code generation”@StartsWith(s). Put the annotation on the constructor parameter or the field.
Example
Section titled “Example”final phone = l.string().startsWith('+');@StartsWith('+') required String phone, // l.string().startsWith("+").required()phone.validate(input)+1-1- valid:
'+44 20 7946 0958' - invalid:
'020 7946 0958'