pub struct Field {
pub name: &'static str,
pub label: &'static str,
pub kind: FieldKind,
pub required: bool,
}Expand description
One input on a create or edit form.
Fields§
§name: &'static strThe form field name. It matches a key of the record.
label: &'static strThe label shown next to the input.
kind: FieldKindThe input type, and how the value is read.
required: boolWhether the form rejects a blank value.
Implementations§
Source§impl Field
impl Field
Sourcepub fn check_required<'a>(
&self,
form: &'a FormInput,
errors: &mut FieldErrors,
) -> Option<&'a str>
pub fn check_required<'a>( &self, form: &'a FormInput, errors: &mut FieldErrors, ) -> Option<&'a str>
Returns the trimmed value of a required field. If it is missing or blank, records “
Sourcepub fn check_whole_number<T: FromStr>(
&self,
text: &str,
errors: &mut FieldErrors,
) -> Option<T>
pub fn check_whole_number<T: FromStr>( &self, text: &str, errors: &mut FieldErrors, ) -> Option<T>
Parses text as a whole number of type T. If it does not parse, records
“
Sourcepub fn check_number(&self, text: &str, errors: &mut FieldErrors) -> Option<f64>
pub fn check_number(&self, text: &str, errors: &mut FieldErrors) -> Option<f64>
Parses text as a number, whole or decimal, such as 42 or 42.5. Values that are
not finite (inf, NaN) are refused. If it does not parse, records
“
Sourcepub fn check_decimal<T: FromStr + Into<f64> + Copy>(
&self,
text: &str,
errors: &mut FieldErrors,
) -> Option<T>
pub fn check_decimal<T: FromStr + Into<f64> + Copy>( &self, text: &str, errors: &mut FieldErrors, ) -> Option<T>
Parses text as a decimal number of type T (f32 or f64), such as 9.5. A
value that is not finite (inf, NaN, or an f32 too large) is refused. If it
does not parse, records “
Sourcepub fn check_datetime(
&self,
text: &str,
errors: &mut FieldErrors,
) -> Option<NaiveDateTime>
pub fn check_datetime( &self, text: &str, errors: &mut FieldErrors, ) -> Option<NaiveDateTime>
Parses text as a date and time: YYYY-MM-DDTHH:MM as a date-time input sends it,
or with a space in place of the T, and with seconds when given. If it does not
parse, records “
Sourcepub fn check_choice(
&self,
text: &str,
choices: &[(&str, &str)],
errors: &mut FieldErrors,
) -> bool
pub fn check_choice( &self, text: &str, choices: &[(&str, &str)], errors: &mut FieldErrors, ) -> bool
Checks that text is the value of one of choices. If it is not, records
“Choose one of the options.” in errors and returns false.
Sourcepub fn check_date(
&self,
text: &str,
errors: &mut FieldErrors,
) -> Option<NaiveDate>
pub fn check_date( &self, text: &str, errors: &mut FieldErrors, ) -> Option<NaiveDate>
Parses text as a YYYY-MM-DD date. If it does not parse, records
“
Trait Implementations§
impl Copy for Field
impl Eq for Field
impl StructuralPartialEq for Field
Auto Trait Implementations§
impl Forget for Field
impl Freeze for Field
impl Move for Field
impl RefUnwindSafe for Field
impl Send for Field
impl Sync for Field
impl Unpin for Field
impl UnsafeUnpin for Field
impl UnwindSafe for Field
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more