v1.3.1 - Stable Release

Ultra-fast TypeScript Validation

VLD is a blazing-fast, type-safe validation library with zero dependencies, 27+ language support, and full Zod API compatibility.

2.07x
Faster than Zod
96.55%
Test Coverage
27+
Languages
0
Dependencies
example.ts
import { v } from '@oxog/vld';

const userSchema = v.object({
  name: v.string().min(2),
  email: v.string().email(),
  age: v.number().min(18).max(100)
});

const result = userSchema.safeParse(data);
// { success: true, data: { name, email, age } }

Why Choose VLD?

Built for performance, designed for developers. Everything you need for runtime validation.

Blazing Fast

2.07x faster than Zod on average. Optimized for V8 engine.

Type-Safe

Full TypeScript support with excellent type inference.

Zero Dependencies

No external runtime dependencies. Lightweight and tree-shakeable.

27+ Languages

Built-in i18n support for error messages in 27+ languages.

Error Formatting

Advanced error formatting: tree, pretty, and flatten utilities.

Zod Compatible

100% Zod API compatible. Drop-in replacement, just change import.

Bidirectional Codecs

19 built-in codecs for encode/decode transformations.

Type Coercion

Automatic type coercion for strings, numbers, booleans, dates.

Quick Start

Get up and running in seconds

Installation

Basic Usage

import { v } from '@oxog/vld';

// Define a schema
const userSchema = v.object({
  name: v.string().min(2),
  email: v.string().email(),
  age: v.number().min(18).optional()
});

// Validate with parse (throws on error)
const user = userSchema.parse({
  name: 'John',
  email: 'john@example.com',
  age: 25
});

// Or use safeParse (returns result object)
const result = userSchema.safeParse(data);
if (result.success) {
  console.log(result.data);
} else {
  console.log(result.error);
}

Type Inference

import { v, Infer } from '@oxog/vld';

const userSchema = v.object({
  name: v.string(),
  email: v.string().email(),
  age: v.number()
});

// Automatically infer the type
type User = Infer<typeof userSchema>;
// { name: string; email: string; age: number }

Documentation

Complete API reference with examples for all validators

View Docs

Real-World Examples

Common validation patterns for everyday use

User Registration Form

Complete form validation with custom messages

const registerSchema = v.object({
  username: v.string()
    .min(3, 'Username too short')
    .max(20, 'Username too long')
    .regex(/^[a-z0-9_]+$/, 'Only lowercase, numbers, underscores'),
  email: v.string().email('Invalid email'),
  password: v.string()
    .min(8, 'Password must be 8+ characters')
    .regex(/[A-Z]/, 'Need uppercase letter')
    .regex(/[0-9]/, 'Need a number'),
  confirmPassword: v.string()
}).refine(
  data => data.password === data.confirmPassword,
  'Passwords must match'
);

API Response Schema

Validate API responses with nested objects

const apiResponseSchema = v.object({
  success: v.boolean(),
  data: v.object({
    users: v.array(v.object({
      id: v.string().uuid(),
      name: v.string(),
      email: v.string().email(),
      role: v.enum('admin', 'user', 'guest'),
      createdAt: v.coerce.date()
    })),
    pagination: v.object({
      page: v.number().int().positive(),
      total: v.number().int().nonnegative(),
      hasMore: v.boolean()
    })
  }),
  meta: v.object({
    requestId: v.string(),
    timestamp: v.coerce.date()
  })
});

Bidirectional Codecs

Encode and decode data transformations

import {
  stringToNumber,
  isoDatetimeToDate,
  jsonCodec
} from '@oxog/vld';

// String to number
const age = stringToNumber.parse('25'); // 25
const str = stringToNumber.encode(25);  // '25'

// ISO date string to Date object
const date = isoDatetimeToDate.parse('2024-01-15T10:30:00Z');
const iso = isoDatetimeToDate.encode(new Date());

// JSON codec with schema
const userCodec = jsonCodec(v.object({
  name: v.string(),
  age: v.number()
}));
const user = userCodec.parse('{"name":"John","age":30}');

Internationalization

Error messages in 27+ languages

import { v, setLocale } from '@oxog/vld';

const schema = v.string().min(5);

// English (default)
setLocale('en');
schema.safeParse('Hi');
// Error: "String must be at least 5 characters"

// Turkish
setLocale('tr');
schema.safeParse('Hi');
// Error: "Metin en az 5 karakter olmalı"

// Japanese
setLocale('ja');
schema.safeParse('Hi');
// Error: "文字列は5文字以上である必要があります"

Interactive Playground

Try VLD in your browser - no installation required

Schema & Data
Output ✓ Valid ✗ Invalid

                        

Performance

VLD destroys the competition

2.07x
Faster
78%
Less Memory
0
Dependencies
VLD Zod ops/sec (higher is better)
Result: VLD wins every time

27+ Languages Supported

Built-in internationalization for error messages

Live Demo