To provide custom error messages, implement the I18n trait. You must provide implementations for all the following rule-related methods. Most methods accept parameters like min/max values, pattern strings, or specific error reason enums (like InvalidEmail or InvalidUrl).
impl I18n for MyLanguage {
fn length_lower_than(&self, min: usize) -> Cow<'static, str>;
fn length_greater_than(&self, max: usize) -> Cow<'static, str>;
fn range_lower_than(&self, min: &dyn Display) -> Cow<'static, str>;
fn range_greater_than(&self, max: &dyn Display) -> Cow<'static, str>;
fn credit_card_invalid(&self, reason: InvalidCreditCard) -> Cow<'static, str>;
fn pattern_no_match(&self, pattern: &dyn Display) -> Cow<'static, str>;
fn contains_missing(&self, pattern: &dyn Display) -> Cow<'static, str>;
fn url_invalid(&self, reason: InvalidUrl) -> Cow<'static, str>;
fn prefix_missing(&self, pattern: &dyn Display) -> Cow<'static, str>;
fn suffix_missing(&self, pattern: &dyn Display) -> Cow<'static, str>;
fn phone_number_invalid(&self, reason: InvalidPhoneNumber) -> Cow<'static, str>;
fn ip_invalid(&self, kind: IpKind) -> Cow<'static, str>;
fn matches_field_mismatch(&self, field: &dyn Display) -> Cow<'static, str>;
fn email_invalid(&self, reason: InvalidEmail) -> Cow<'static, str>;
fn ascii_invalid(&self) -> Cow<'static, str>;
fn alphanumeric_invalid(&self) -> Cow<'static, str>;
fn required_not_set(&self) -> Cow<'static, str>;
}