The problem: Zod (the most popular validation library) doesn't have FormData support. It's their #1 requested feature with 60+ upvotes on GitHub [1], but they haven't implemented it.
So every Server Action looks like this:
const name = formData.get('name') as string;
const age = parseInt(formData.get('age') as string);
// ... manual validation
I wanted: const result = validateFormData(formData, schema);
// Automatic type conversion, validation done
While building this, I also added:
- Partial validation (return valid data even with errors - useful for auto-save)
- JSON Schema export (built-in, no external package needed)
- File validation (size, MIME types)
- XOR support (exactly one of these fields)Zero dependencies. 3KB. MIT licensed.
GitHub: https://github.com/YOUR_USERNAME/lite-schema-check npm: npm install lite-schema-check
Technical details in README. Happy to answer questions about the implementation.
[1] https://github.com/colinhacks/zod/discussions (search for FormData)