pub struct BlockFieldMeta {
pub min_length: Option<u32>,
pub max_length: Option<u32>,
pub pattern: Option<String>,
pub min_value: Option<f64>,
pub max_value: Option<f64>,
pub default_value: Option<String>,
pub chooser_filter: Option<String>,
}Expand description
Per-field validators threaded into the rendered widget’s HTML5
attributes (minlength, maxlength, pattern, min, max)
- the block-field-side initial value. Default value is “no constraints”, so existing call sites get backwards-compatible behaviour after the migration to the sub-struct.
Fields§
§min_length: Option<u32>HTML5 minlength on string-shaped widgets (Text, Textarea,
Email, URL, Password, Tel).
max_length: Option<u32>HTML5 maxlength on string-shaped widgets. Mirrors
Widget::max_length already on the rendered widget — the
meta entry wins when both are set.
pattern: Option<String>HTML5 pattern regex on string-shaped widgets. Browser
validates on form submit; the server should re-validate
(TODO: server-side enforcement is a follow-up).
min_value: Option<f64>HTML5 min on numeric / date widgets. Distinct from
Widget::min already on the rendered widget — the meta entry
wins when both are set.
max_value: Option<f64>HTML5 max on numeric / date widgets.
default_value: Option<String>Initial value when a fresh instance of this widget is
inserted. Serialised through the widget’s value field so
the editor shows the default in the empty-block template.
chooser_filter: Option<String>Narrows a snippet chooser to one library type (its type_name),
e.g. "form" so the picker lists forms only.
Implementations§
Source§impl BlockFieldMeta
impl BlockFieldMeta
Sourcepub fn none() -> Self
pub fn none() -> Self
Empty meta — sensible default for the 19 built-in blocks that don’t declare any per-field constraints.
Sourcepub fn is_default(&self) -> bool
pub fn is_default(&self) -> bool
true when every option is None — used by serde to skip
the meta slot on the wire when no validators are set.
Sourcepub fn min_length(self, n: u32) -> Self
pub fn min_length(self, n: u32) -> Self
Fluent: set HTML5 minlength.
Sourcepub fn max_length(self, n: u32) -> Self
pub fn max_length(self, n: u32) -> Self
Fluent: set HTML5 maxlength.
Sourcepub fn default_value(self, v: impl Into<String>) -> Self
pub fn default_value(self, v: impl Into<String>) -> Self
Fluent: set widget initial value.
Sourcepub fn chooser_filter(self, type_name: impl Into<String>) -> Self
pub fn chooser_filter(self, type_name: impl Into<String>) -> Self
Fluent: narrow a snippet chooser to one library type.
Trait Implementations§
Source§impl Clone for BlockFieldMeta
impl Clone for BlockFieldMeta
Source§impl Debug for BlockFieldMeta
impl Debug for BlockFieldMeta
Source§impl Default for BlockFieldMeta
impl Default for BlockFieldMeta
Auto Trait Implementations§
impl Forget for BlockFieldMeta
impl Freeze for BlockFieldMeta
impl RefUnwindSafe for BlockFieldMeta
impl Send for BlockFieldMeta
impl Sync for BlockFieldMeta
impl Unpin for BlockFieldMeta
impl UnsafeUnpin for BlockFieldMeta
impl UnwindSafe for BlockFieldMeta
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<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