dmc-schema 0.1.0

Velite-style schema builders for dmc collection records
Documentation

Schema builder. s::*

use dmc_schema::{s, BoxSchema, Ctx, Schema};
use serde_json::json;

let schema = s::object(vec![
    ("title".into(), s::string().max(99).boxed()),
    ("draft".into(), s::default_(s::boolean().boxed(), json!(false)).boxed()),
]);
let ctx = Ctx::empty();
let out = schema.parse(&json!({"title": "Hello"}), &ctx).unwrap();
assert_eq!(out["title"], "Hello");
assert_eq!(out["draft"], false);