Validators
A validator is a function that assesses the validity of a field's value (one validator per
field). Fields can have up to two validators (primary and re-validator) - see the
root README for the full definitions of
validator, re-validator, post-validator and required resolver, which apply the same way in
Rust as in TypeScript.
- Validators & re-validators: see lax fields, required fields and virtual fields
- Custom required errors: see this example
Built-in validation helpers
Enable the optional validators feature (ivo = { version = "*", features = ["validators"] },
crate ivo-validators) for a small set of built-in validators:
validate_email(value: &str) -> Result<String, String>validate_credit_card(value: &str) -> Result<String, String>
See the
crate source for
implementation details, and main_demo
for a schema that uses them.