pub struct DurationField {
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 ISO 8601 duration validation
Validates that the input is a valid ISO 8601 duration format (e.g., “P1Y2M3DT4H5M6S”).
§Examples
use reinhardt_forms::fields::DurationField;
use reinhardt_forms::Field;
use serde_json::json;
let field = DurationField::new("duration");
let result = field.clean(Some(&json!("P1Y2M3DT4H5M6S")));
assert!(result.is_ok());
let result = field.clean(Some(&json!("P1D")));
assert!(result.is_ok());Fields§
§name: String§required: bool§error_messages: HashMap<String, String>§widget: Widget§help_text: String§initial: Option<Value>Implementations§
Source§impl DurationField
impl DurationField
Trait Implementations§
Source§impl Clone for DurationField
impl Clone for DurationField
Source§fn clone(&self) -> DurationField
fn clone(&self) -> DurationField
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 DurationField
impl Debug for DurationField
Source§impl FormField for DurationField
impl FormField for DurationField
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 DurationField
impl RefUnwindSafe for DurationField
impl Send for DurationField
impl Sync for DurationField
impl Unpin for DurationField
impl UnsafeUnpin for DurationField
impl UnwindSafe for DurationField
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