Function passablewords::check_password [] [src]

pub fn check_password(password: &str) -> PassablewordResult

Check a password's length, uniqueness, and entropy all in a single call. This is a convenience method and simply calls check_length, check_uniqueness, and check_entropy with the password supplied.

Example (using rocket.rs)

match check_password(password) {
    Ok() => status::Ok
    Err(err) => match(err) {
        PassablewordResult::TooShort => status::BadRequest("Your password should be longer than 8 characters"),
        PassablewordResult::TooCommon => status::BadRequest("Your should be more unique"),
        PassablewordResult::TooSimple => status::BadRequest("Your should be more random"),
        PassablewordResult::InternalError => status::InternalServerError
    }
}