pub struct PasswordField {
pub name: String,
pub required: bool,
pub error_messages: HashMap<String, String>,
pub widget: Widget,
pub help_text: String,
pub initial: Option<Value>,
pub min_length: usize,
pub require_uppercase: bool,
pub require_lowercase: bool,
pub require_digit: bool,
pub require_special: bool,
}Expand description
A field for password validation with strength requirements
Validates password strength including minimum length, required character types.
§Examples
use reinhardt_forms::fields::PasswordField;
use reinhardt_forms::Field;
use serde_json::json;
let field = PasswordField::new("password")
.min_length(8)
.require_uppercase(true)
.require_digit(true);
// Valid strong password
let result = field.clean(Some(&json!("SecurePass123")));
assert!(result.is_ok());
// Invalid: too short
let result = field.clean(Some(&json!("Pass1")));
assert!(result.is_err());Fields§
§name: StringThe field name used as the form data key.
required: boolWhether this field must be filled in.
error_messages: HashMap<String, String>Custom error messages keyed by error type.
widget: WidgetThe widget type used for rendering this field.
help_text: StringHelp text displayed alongside the field.
initial: Option<Value>Optional initial (default) value for the field.
min_length: usizeMinimum required password length.
require_uppercase: boolWhether the password must contain at least one uppercase letter.
require_lowercase: boolWhether the password must contain at least one lowercase letter.
require_digit: boolWhether the password must contain at least one digit.
require_special: boolWhether the password must contain at least one special character.
Implementations§
Source§impl PasswordField
impl PasswordField
Sourcepub fn min_length(self, length: usize) -> Self
pub fn min_length(self, length: usize) -> Self
Set minimum length
Sourcepub fn require_uppercase(self, required: bool) -> Self
pub fn require_uppercase(self, required: bool) -> Self
Require uppercase letter
Sourcepub fn require_lowercase(self, required: bool) -> Self
pub fn require_lowercase(self, required: bool) -> Self
Require lowercase letter
Sourcepub fn require_digit(self, required: bool) -> Self
pub fn require_digit(self, required: bool) -> Self
Require digit
Sourcepub fn require_special(self, required: bool) -> Self
pub fn require_special(self, required: bool) -> Self
Require special character
Trait Implementations§
Source§impl Clone for PasswordField
impl Clone for PasswordField
Source§fn clone(&self) -> PasswordField
fn clone(&self) -> PasswordField
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more