pub struct UUIDField {
pub name: String,
pub required: bool,
pub error_messages: HashMap<String, String>,
pub widget: Widget,
pub help_text: String,
pub initial: Option<Value>,
}Expand description
A field for UUID validation
Validates that the input is a valid UUID (Universally Unique Identifier). Supports UUID v4 by default.
§Examples
use reinhardt_forms::fields::UUIDField;
use reinhardt_forms::Field;
use serde_json::json;
let field = UUIDField::new("id");
// Valid UUID v4
let result = field.clean(Some(&json!("550e8400-e29b-41d4-a716-446655440000")));
assert!(result.is_ok());
// Invalid UUID
let result = field.clean(Some(&json!("not-a-uuid")));
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.
Implementations§
Trait Implementations§
Source§impl FormField for UUIDField
impl FormField for UUIDField
Source§fn initial(&self) -> Option<&Value>
fn initial(&self) -> Option<&Value>
Returns the initial (default) value for this field, if any.
Source§fn clean(&self, value: Option<&Value>) -> FieldResult<Value>
fn clean(&self, value: Option<&Value>) -> FieldResult<Value>
Validates and cleans the submitted value, returning the cleaned result.
Auto Trait Implementations§
impl Freeze for UUIDField
impl RefUnwindSafe for UUIDField
impl Send for UUIDField
impl Sync for UUIDField
impl Unpin for UUIDField
impl UnsafeUnpin for UUIDField
impl UnwindSafe for UUIDField
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