green_barrel/fields/
password.rs1use core::fmt::Debug;
4use serde::{Deserialize, Serialize};
5
6#[derive(Serialize, Deserialize, Clone, Debug)]
7pub struct PasswordField {
8 pub id: String, pub label: String, pub field_type: String, pub input_type: String, pub name: String, pub value: Option<String>, pub placeholder: String, pub regex: String, pub regex_err_msg: String, pub minlength: usize, pub maxlength: usize, pub required: bool, pub disabled: bool, pub readonly: bool, pub is_hide: bool, pub other_attrs: String,
25 pub css_classes: String, pub hint: String, pub warning: String, pub errors: Vec<String>, pub group: u32, }
31
32impl Default for PasswordField {
33 fn default() -> Self {
34 Self {
35 id: String::new(),
36 label: String::new(),
37 field_type: String::from("PasswordField"),
38 input_type: String::from("password"),
39 name: String::new(),
40 value: None,
41 placeholder: String::new(),
42 regex: String::from("^[a-zA-Z0-9@#$%^&+=*!~)(]{8,256}$"),
43 regex_err_msg: t!(
44 "allowed_chars",
45 chars = "a-z A-Z 0-9 @ # $ % ^ & + = * ! ~ ) ("
46 ),
47 minlength: 8,
48 maxlength: 256,
49 required: false,
50 disabled: false,
51 readonly: false,
52 is_hide: false,
53 other_attrs: String::new(),
54 css_classes: String::new(),
55 hint: String::new(),
56 warning: String::new(),
57 errors: Vec::new(),
58 group: 1,
59 }
60 }
61}
62
63impl PasswordField {
64 pub fn get(&self) -> Option<String> {
65 self.value.clone()
66 }
67 pub fn set(&mut self, value: &str) {
68 self.value = Some(String::from(value));
69 }
70}