Skip to main content

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:
npm 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:
test.ts
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');
1

Save the file

Save the code above as test.ts (or test.js for JavaScript)
2

Run the file

Execute the file using Node.js or your TypeScript runner:
npx tsx test.ts
or for JavaScript:
node test.js
3

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:
tsconfig.json
{
  "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

Build docs developers (and LLMs) love