Integrations Overview
validup keeps a pure-JS core. Integration packages bridge an existing validation library or a host framework into the Container / Validator / Issue model.
Two shapes
Validator adapters expose a createValidator() function that returns a validup Validator:
typescript
import { createValidator } from '@validup/zod';
import { z } from 'zod';
container.mount('email', createValidator(z.string().email()));These come in three flavors today:
| Package | Wraps | Pick when… |
|---|---|---|
@validup/standard-schema | Any Standard Schema library (zod 3.24+, valibot, arktype, …) | You want vendor-neutral schemas |
@validup/zod | zod v3.25+ / v4 | You need vendor-specific issue fields (expected, received) |
@validup/express-validator | express-validator chains | You already have express-validator chains |
Framework / runtime integrations consume a whole Container<T, C> and wire it into a host environment:
| Package | Host |
|---|---|
@validup/routup | routup HTTP requests |
@validup/vue | Vue 3 reactive forms |
Writing your own
If you want to bridge another library, copy the shape of @validup/zod:
typescript
import { type Validator, type ValidatorContext, ValidupError } from 'validup';
type CreateFn<C> = (ctx: ValidatorContext<C>) => Schema;
export function createValidator<C = unknown>(input: Schema | CreateFn<C>): Validator<C> {
return async (ctx): Promise<unknown> => {
const schema = typeof input === 'function' ? input(ctx) : input;
const outcome = await schema.safeParseAsync(ctx.value);
if (outcome.success) return outcome.data;
throw new ValidupError(buildIssuesForError(outcome.error));
};
}Three contract points to preserve:
- Accept either a schema or a
(ctx) => schemafactory. - Make
createValidator<C>generic over the validup context. - Translate foreign errors into
Issue[]usingdefineIssueItem/defineIssueGroup— never construct issue objects literally.
For framework integrations, study @validup/routup (try-each-location HTTP adapter) or @validup/vue (reactive composable that drives form state from safeRun()).