Prerequisites
Before installing PolyVal, ensure you have:
- Node.js version 14 or higher
- npm, yarn, or pnpm package manager
Install PolyVal
Choose your preferred package manager to install PolyVal:
PolyVal automatically includes Zod as a dependency, so you don’t need to install it separately.
Verify installation
Create a simple test file to verify that PolyVal is installed correctly:
import { validate } from 'polyval';
const schema = {
name: {
type: 'string',
required: true
}
};
const data = { name: 'John' };
const errors = validate(schema, data, { lang: 'en' });
console.log(errors.length === 0 ? 'PolyVal is working!' : 'Validation failed');
Save the file
Save the code above as test.ts (or test.js for JavaScript)
Run the file
Execute the file using Node.js or your TypeScript runner:or for JavaScript: Check the output
You should see “PolyVal is working!” in your console
TypeScript configuration
If you’re using TypeScript, ensure your tsconfig.json includes the following settings:
{
"compilerOptions": {
"target": "ES2020",
"module": "commonjs",
"esModuleInterop": true,
"strict": true,
"skipLibCheck": true
}
}
PolyVal is fully typed, so you’ll get autocomplete and type checking in your IDE when using TypeScript.
Next steps
Quickstart guide
Learn how to create your first validation schema and validate data