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: String§required: bool§error_messages: HashMap<String, String>§widget: Widget§help_text: String§initial: Option<Value>§min_length: usize§require_uppercase: bool§require_lowercase: bool§require_digit: bool§require_special: boolImplementations§
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
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for PasswordField
impl Debug for PasswordField
Source§impl FormField for PasswordField
impl FormField for PasswordField
fn name(&self) -> &str
fn label(&self) -> Option<&str>
fn widget(&self) -> &Widget
fn required(&self) -> bool
fn initial(&self) -> Option<&Value>
fn help_text(&self) -> Option<&str>
fn clean(&self, value: Option<&Value>) -> FieldResult<Value>
Auto Trait Implementations§
impl Freeze for PasswordField
impl RefUnwindSafe for PasswordField
impl Send for PasswordField
impl Sync for PasswordField
impl Unpin for PasswordField
impl UnsafeUnpin for PasswordField
impl UnwindSafe for PasswordField
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more