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§
Sourcefn code(&self) -> &'static str
fn code(&self) -> &'static str
Stable identifier ("length", "numeric", …). Useful for
docs, tests, and template branches.
Sourcefn validate(
&self,
password: &str,
user_attrs: &UserAttributes,
) -> Result<(), ValidationError>
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§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".