pub struct ImageField {
pub name: String,
pub label: Option<String>,
pub required: bool,
pub help_text: Option<String>,
pub widget: Widget,
pub initial: Option<Value>,
pub max_length: Option<usize>,
pub allow_empty_file: bool,
pub max_size: u64,
}Expand description
ImageField for image upload with additional validation
Fields§
§name: StringThe field name used as the form data key.
label: Option<String>Optional human-readable label for display.
required: boolWhether an image must be uploaded.
help_text: Option<String>Optional help text displayed alongside the field.
widget: WidgetThe widget type used for rendering this field.
initial: Option<Value>Optional initial (default) value for the field.
max_length: Option<usize>Maximum allowed filename length.
allow_empty_file: boolWhether to accept empty (zero-byte) files.
max_size: u64Maximum file size in bytes. Defaults to 5 MB.
Implementations§
Source§impl ImageField
impl ImageField
Sourcepub fn new(name: String) -> Self
pub fn new(name: String) -> Self
Create a new ImageField
§Examples
use reinhardt_forms::fields::ImageField;
let field = ImageField::new("photo".to_string());
assert_eq!(field.name, "photo");
assert_eq!(field.max_size, 5 * 1024 * 1024);Sourcepub fn with_max_size(self, max_size: u64) -> Self
pub fn with_max_size(self, max_size: u64) -> Self
Set the maximum file size in bytes.
§Examples
use reinhardt_forms::fields::ImageField;
let field = ImageField::new("photo".to_string()).with_max_size(2 * 1024 * 1024);
assert_eq!(field.max_size, 2 * 1024 * 1024);Trait Implementations§
Source§impl FormField for ImageField
impl FormField for ImageField
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 ImageField
impl RefUnwindSafe for ImageField
impl Send for ImageField
impl Sync for ImageField
impl Unpin for ImageField
impl UnsafeUnpin for ImageField
impl UnwindSafe for ImageField
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