valicore: Runtime Type Validation for TypeScript (Schemas, Guards, Parsing)
TypeScript is great for catching type errors at compile time — but what about runtime? External API responses, form data, env vars — they're all untyped at runtime. valicore fixes that. What is val...

Source: DEV Community
TypeScript is great for catching type errors at compile time — but what about runtime? External API responses, form data, env vars — they're all untyped at runtime. valicore fixes that. What is valicore? A zero-dependency TypeScript validation library with full schema inference, type guards, and safe parsing. npm install valicore bun add valicore Core Features Schema Definition import { v } from 'valicore'; const UserSchema = v.object({ id: v.number(), name: v.string().min(1).max(100), email: v.string().email(), role: v.enum(['admin', 'user', 'guest']), createdAt: v.date().optional() }); type User = v.infer<typeof UserSchema>; // Automatically inferred TypeScript type! Safe Parsing const result = UserSchema.safeParse(apiResponse); if (result.success) { console.log(result.data.email); // Fully typed! } else { console.error(result.errors); // Detailed error messages } Type Guards if (UserSchema.is(data)) { // data is narrowed to User type here sendWelcomeEmail(data.email); } Nested