Skip to main content

PasswordValidator

Trait PasswordValidator 

Source
pub trait PasswordValidator: Send + Sync {
    // Required methods
    fn code(&self) -> &'static str;
    fn validate(
        &self,
        password: &str,
        user_attrs: &UserAttributes,
    ) -> Result<(), ValidationError>;

    // Provided method
    fn help_text(&self) -> String { ... }
}
Expand description

One link in the chain. validate returns Ok(()) on pass; one ValidationError on failure. The chain runs every validator and collects errors (not short-circuit) so users see the full problem set per round-trip.

Required Methods§

Source

fn code(&self) -> &'static str

Stable identifier ("length", "numeric", …). Useful for docs, tests, and template branches.

Source

fn validate( &self, password: &str, user_attrs: &UserAttributes, ) -> Result<(), ValidationError>

Validate password against user_attrs. Implementations SHOULD NOT log or store the password.

Provided Methods§

Source

fn help_text(&self) -> String

Help text the UI shows next to the password field. Default empty — override to surface the validator’s requirement.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§