VLD is a blazing-fast, type-safe validation library with zero dependencies, 27+ language support, and full Zod API compatibility.
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 } }
Built for performance, designed for developers. Everything you need for runtime validation.
2.07x faster than Zod on average. Optimized for V8 engine.
Full TypeScript support with excellent type inference.
No external runtime dependencies. Lightweight and tree-shakeable.
Built-in i18n support for error messages in 27+ languages.
Advanced error formatting: tree, pretty, and flatten utilities.
100% Zod API compatible. Drop-in replacement, just change import.
19 built-in codecs for encode/decode transformations.
Automatic type coercion for strings, numbers, booleans, dates.
Get up and running in seconds
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);
}
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 }
Common validation patterns for everyday use
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'
);
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()
})
});
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}');
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文字以上である必要があります"
Try VLD in your browser - no installation required
VLD destroys the competition
Built-in internationalization for error messages