pub struct DecimalField {Show 13 fields
pub name: String,
pub label: Option<String>,
pub required: bool,
pub help_text: Option<String>,
pub widget: Widget,
pub initial: Option<Value>,
pub max_value: Option<f64>,
pub min_value: Option<f64>,
pub max_digits: Option<usize>,
pub decimal_places: Option<usize>,
pub localize: bool,
pub locale: Option<String>,
pub use_thousands_separator: bool,
}Expand description
DecimalField for decimal number input with digit and precision validation.
Precision Note: This field stores values internally as f64 (IEEE 754),
which provides approximately 15-17 significant decimal digits of precision.
All digit count and decimal place validations are performed on the string
representation before conversion to f64, ensuring accurate constraint
enforcement even for values that cannot be exactly represented in binary
floating-point.
For applications requiring exact decimal arithmetic (e.g., financial
calculations), consider using rust_decimal::Decimal in your application
layer after form validation.
Fields§
§name: String§label: Option<String>§required: bool§help_text: Option<String>§widget: Widget§initial: Option<Value>§max_value: Option<f64>§min_value: Option<f64>§max_digits: Option<usize>§decimal_places: Option<usize>§localize: bool§locale: Option<String>§use_thousands_separator: boolImplementations§
Source§impl DecimalField
impl DecimalField
Sourcepub fn new(name: String) -> Self
pub fn new(name: String) -> Self
Create a new DecimalField
§Examples
use reinhardt_forms::fields::DecimalField;
let field = DecimalField::new("price".to_string());
assert_eq!(field.name, "price");
assert!(field.required);pub fn with_localize(self, localize: bool) -> Self
pub fn with_locale(self, locale: String) -> Self
pub fn with_thousands_separator(self, use_separator: bool) -> Self
Trait Implementations§
Source§impl FormField for DecimalField
impl FormField for DecimalField
fn name(&self) -> &str
fn label(&self) -> Option<&str>
fn required(&self) -> bool
fn help_text(&self) -> Option<&str>
fn widget(&self) -> &Widget
fn initial(&self) -> Option<&Value>
fn clean(&self, value: Option<&Value>) -> FieldResult<Value>
Auto Trait Implementations§
impl Freeze for DecimalField
impl RefUnwindSafe for DecimalField
impl Send for DecimalField
impl Sync for DecimalField
impl Unpin for DecimalField
impl UnsafeUnpin for DecimalField
impl UnwindSafe for DecimalField
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