Skip to main content

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.

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.