Catfive 🌪️
Catfive is a category-5, fluent, zero-dependency schema and form validation library for Rust.
Inspired by developer-friendly schema libraries like Zod, Catfive gives you composable, expressive validation rules without forcing procedural attribute macros (#[derive(...)]) onto your structs.
Highlights
- ⚡ Macro-Free: Clean, functional, and composable builder API without
#[derive(Validate)]. - 📦 Zero Dependencies by Default: Core validators operate entirely on the Rust standard library (
std). - 🔍 Detailed & Actionable Errors: Rules like
.block("...")report the exact offending character for audit logging. - 📋 Form & Struct Schemas: Validate untyped key-value form submissions or strongly-typed Rust data structures.
- 🎯 Optional Regex: Enable the
regexfeature flag whenever you need complex pattern matching.
Installation
Add Catfive to your Cargo.toml:
[]
= "0.1.0"
To enable regular expression support:
[]
= { = "0.1.0", = ["regex"] }
Quick Start
1. Standalone String Validator & .block()
Block specific characters from user input and inspect exactly which forbidden character triggered the validation error:
use string;
2. Validating Forms (Key-Value Payloads)
Perfect for HTTP requests, query params, and HTML forms:
use HashMap;
use ;
3. Validating Structs Without Macros
Define schemas for arbitrary structs using typed field selectors:
use ;
4. Optional Regex Support
use string;
let code_validator = string.regex;
assert!;
License
This project is licensed under the MIT License.