Skip to main content

Crate formars_core

Crate formars_core 

Source
Expand description

formars-core: typed schema primitives with a dyn-safe erased view. Fluent builder schemas for validation, coercion and introspection — the kernel every other formars* crate builds on.

A schema is a value you build, compose, and pass around:

use formars_core::prelude::*;

let s = string().trim().min(2).max(5);
assert!(s.parse(&"ab".to_string()).is_ok());

Every builder simultaneously implements the typed schema::Schema trait and the object-safe schema::DynSchema erased view from one internal representation, so both views always agree. Object schemas compose any builder family into struct-shaped validation over an ordered Value::Object:

use formars_core::prelude::*;

let user = object()
    .field("name", string().min(1).label("Full name"))
    .field("age", coerced::<u32>());

Modules§

coerce
String-to-type coercion schemas.
error
Error model: accumulated, path-addressed issues. Accumulated, path-addressed validation errors.
form
Struct↔schema contracts and value bridging for the opt-in formars-derive crate. Struct↔schema contracts and value bridging used by the opt-in formars-derive crate — macro-free, dependency-free additions to core.
prelude
Curated re-exports for typical users. Curated re-exports for typical users.
rule
Custom validation rules that compose identically to built-in checks. Custom validation rules that compose identically to built-in checks.
schema
The two validation views and their shared introspection types. The two validation views and their shared introspection types.
types
Primitive schema builders and their constructors.
validators
Pragmatic hand-rolled format validators (no regex dependency in v0).
value
Dependency-free dynamic value tree and its accessors.