formatErrorMessage method
Formats the error map into a human-readable error message.
This method is called by validateOrThrow to create the error message for the ArgumentError.
Subclasses should override this method to provide custom error messages that are appropriate for their validation rules.
Parameters:
error: The error map returned by validate
Returns:
- A human-readable error message string
Implementation
@override
String formatErrorMessage(Map<String, dynamic> error) {
if (error.containsKey(emptyError)) {
final details = error[emptyError] as Map<String, dynamic>;
final actual = details['actual'] as String;
return '$fieldName cannot be empty. Actual: "$actual"';
}
return 'Invalid $fieldName value';
}