Creates a new SimpleMessagesProvider instance.
Map of validation rule names to error message templates
Optionalfields: ValidationFieldsOptional map of field paths to human-readable names
Returns a validation error message for a given field and rule. Uses a priority-based lookup system to find the most specific message.
Priority order:
The default raw message from the validation rule
The name of the validation rule that failed
Context information about the field being validated
Optionalargs: Record<string, any>Additional arguments to interpolate into the message
Formatted and interpolated error message
// With field-specific message
provider.getMessage('Required', 'required', fieldContext, {})
// Returns: "Email address is required" (if field-specific message exists)
// With rule arguments
provider.getMessage('Min length', 'minLength', fieldContext, { min: 5 })
// Returns: "The username must be at least 5 characters"
Serializes the messages provider to a JSON-compatible object. Useful for debugging, logging, or transferring configuration.
Object containing messages and field mappings
Default messages provider that performs message lookup using key-value pairs. Provides internationalization and custom error message support for validation. Supports field-specific messages, wildcard patterns, and placeholder interpolation.
Example