buildMessage method
Builds a validation error message by replacing placeholders in the error message template.
This method is used to construct an error message for validation failures.
It replaces placeholders in the message
template with actual values.
Parameters:
attribute
: The identifier of the form attribute being validated.input
: The input value that failed validation.onExtra
: A callback function to perform additional message modifications.
Returns: The constructed validation error message.
Implementation
String buildMessage(
String attribute,
String input, {
String Function(String)? onExtra,
}) {
var msg = message;
msg = msg.replaceAll(":attribute", attribute);
msg = msg.replaceAll(":input", input);
if (onExtra != null) {
msg = onExtra(msg);
}
return msg;
}