MessageResolver class

Turns issue codes into messages.

Order of lookup:

  1. the message set on the rule (.min(3, message: '...'))
  2. messages['path.code'], like email.required or items.*.name.required
  3. messages['code'], like required
  4. the default English template

For i18n, extend this class and override resolve, then set MessageResolver.global or pass it to safeParse(messages: ...).

Constructors

MessageResolver({Map<String, String> messages = const <String, String>{}})

Properties

hashCode → int
The hash code for this object.
no setterinherited
messages → Map<String, String>
The custom templates, by key.
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

format(String template, Map<String, Object?> params) → String
Fill placeholders in template.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
resolve(MessageRequest request) → String
Build the final message.
setMessages(Map<String, String> messages) → void
Add or replace templates.
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Properties

global ↔ MessageResolver
The resolver used when none is passed to parse.
getter/setter pair