Skip to content

Zod

Every identifier exports a matching pair of Zod schemas from the /zod sub-path:

import {
// Personal
peselSchema, peselParseSchema,
idCardSchema, idCardParseSchema,
passportSchema, passportParseSchema,
// Tax & Business
nipSchema, nipParseSchema,
vatEuSchema, vatEuParseSchema,
regonSchema, regonParseSchema,
krsSchema, krsParseSchema,
// Banking
nrbSchema, nrbParseSchema,
ibanSchema, ibanParseSchema,
} from '@slashlab/numerik-js/zod'
SchemaSignatureDescription
*Schema(strict?: boolean) => ZodStringValidates the string; errors surface as Zod issues.
*ParseSchema(strict?: boolean) => ZodPipe<ZodString, ZodTransform<T, string>>Validates and transforms to the value object type T.

Both accept the same optional strict parameter as their Numerik.*() factory counterpart — see Strict mode.

import { z } from 'zod'
import { peselSchema, peselParseSchema } from '@slashlab/numerik-js/zod'
// Validate only
const formSchema = z.object({
pesel: peselSchema(),
})
// Validate and transform to a Pesel value object
const parseFormSchema = z.object({
pesel: peselParseSchema(),
})
const result = parseFormSchema.parse({ pesel: '92060512186' })
result.pesel.getBirthDate() // Date — 1992-06-05

Use a *Schema when you only need pass/fail validation as part of a larger Zod object (e.g. a form). Use a *ParseSchema when you also want the parsed value object — its getters — available on the result.