larzvalidate
Validate input against a schema.
Data from forms, APIs and files is untrustworthy - fields go missing, numbers arrive as text. larzvalidate lets you declare what valid data looks like and checks input against it, returning clean type-coerced data or clear per-field error messages. The gatekeeper every real app needs.
larzscript pkg install validate
What you get
- Declare a schema of Field rules
- Type coercion + clear errors
- required/min/max/pattern/choices
- For forms and APIs
Try it
import "validate" as validate
print(validate.is_email("a@b.com"))
print(validate.is_url("https://x.com/y"))
print(validate.has_path_traversal("../etc"))
let s = validate.schema({
"name": validate.field("string", true, nil, nil, nil, nil),
"age": validate.field("number", false, 0, 150),
"role": validate.field("string", true, nil, nil, nil, ["admin", "user"])
})
let result = validate.validate_schema({"name": "Ada", "age": "36", "role": "admin"}, s)
print(result["valid"], result["data"]["age"])Output
true true true true 36
Why it's in the Larz Stack
larzvalidate is a real Larzscript package (larzscript pkg install validate) - money-native, zero dependencies, the same language as the rest of the estate, not a separate Python runtime. It composes with the rest of the Larz Stack and the Larz framework.