pub struct Schema { /* private fields */ }Expand description
Composes fields and layout blocks and resolves every field once into one list.
Implementations§
Source§impl Schema
impl Schema
Sourcepub fn new(children: impl IntoSchema) -> Self
pub fn new(children: impl IntoSchema) -> Self
Builds a Schema from any IntoSchema and reports duplicate field names as declaration
errors.
pub fn empty() -> Self
Sourcepub async fn render<'a>(
&self,
cx: &'a Cx,
source: Source<'_>,
) -> Result<BoxView<'a>>
pub async fn render<'a>( &self, cx: &'a Cx, source: Source<'_>, ) -> Result<BoxView<'a>>
Renders the schema from source and fails with declaration errors instead of rendering.
§Errors
A misdeclared schema fails with its errors rather than render.
Sourcepub fn normalize_values(&self, values: &mut HashMap<String, String>)
pub fn normalize_values(&self, values: &mut HashMap<String, String>)
Rewrites submitted values into their fields’ stored spelling and leaves empty submissions empty for the presence rule to refuse.
Sourcepub fn unknown_keys(&self, values: &HashMap<String, String>) -> Vec<String>
pub fn unknown_keys(&self, values: &HashMap<String, String>) -> Vec<String>
Lists keys in values that no declared input owns, sorted, so handlers reject
client-controlled writes.
Sourcepub fn declaration_errors(&self) -> Vec<DeclarationErrorKind>
pub fn declaration_errors(&self) -> Vec<DeclarationErrorKind>
Reports what is wrong with this declaration: a field whose lens binds no single column, and two fields sharing a name.
Sourcepub fn validate(&self, values: &HashMap<String, String>) -> FieldErrors
pub fn validate(&self, values: &HashMap<String, String>) -> FieldErrors
Validates submitted values against declared inputs, treating absent keys as empty and skipping fields in absent repeater groups and hidden variant groups.
Sourcepub async fn validate_async(
&self,
cx: &Cx,
values: &HashMap<String, String>,
) -> FieldErrors
pub async fn validate_async( &self, cx: &Cx, values: &HashMap<String, String>, ) -> FieldErrors
Validates submissions and then probes each visible choice’s option existence.