call method

  1. @override
String? call(
  1. String attribute,
  2. String value
)
override

Validates whether a value starts with the specified pattern.

This method checks if the input value starts with the provided pattern. If the value does not start with the pattern, an error message is generated using the buildMessage method.

Parameters:

  • attribute: The identifier of the form attribute being validated.
  • value: The value to be validated.

Returns: A validation error message if the value does not start with the pattern, or null if the value starts with the pattern.

Implementation

@override
String? call(String attribute, String value) {
  if (value.isNotEmpty) {
    if (!value.startsWith(pattern)) {
      return buildMessage(attribute, value, onExtra: (message) {
        message.replaceAll(':pattern', pattern);
        return message;
      });
    }
  }
  return null;
}