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: String§label: Option<String>§required: bool§help_text: Option<String>§widget: Widget§initial: Option<Value>§max_length: Option<usize>§allow_empty_file: bool§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
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 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