Getting Started
Install and configure valrs in your project
Getting Started
This guide will help you install valrs and start validating data in minutes.
Installation
Install valrs using your preferred package manager:
Basic Usage
Import and Create Schemas
Define Object Schemas
Handle Validation Errors
When validation fails, parse() throws a ValError with a Zod-compatible API:
For safe parsing without exceptions:
TypeScript Integration
valrs provides full type inference. Define your schema once and get types automatically:
Input vs Output Types
When using transforms, input and output types may differ:
Framework Integration
React
Next.js Server Actions
Express.js Middleware
WASM Initialization (Optional)
For maximum performance in browsers, you can explicitly initialize the WebAssembly module:
WASM initialization is automatic in most environments. You only need to call init() explicitly if you want to control when the WASM binary is loaded.
Next Steps
- Primitives - All primitive types and their methods
- Objects - Object schemas and manipulation
- Collections - Arrays, tuples, records, maps, and sets
- Streaming - O(1) memory validation for large files