pub trait MessageResolver {
// Required method
fn resolve(&self, key: &str) -> Option<String>;
// Provided method
fn plural_category(&self, n: u64) -> &'static str { ... }
}Expand description
Trait for resolving validation messages by error code key.
Implementations receive the template keys of IssueCode::message_keys()
(most specific first, e.g. "too_small.string" then "too_small") and
return a template, or None to try the next key / keep the original message.
Templates can use {param_name} placeholders that will be filled from
IssueCode::params().
Required Methods§
Provided Methods§
Sourcefn plural_category(&self, n: u64) -> &'static str
fn plural_category(&self, n: u64) -> &'static str
Plural category of n ("one", "few", "many", "other") for
templates with count variants (see translate_issue). Default:
English rule (plural_en).
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".