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'Schema pairs
Section titled “Schema pairs”| Schema | Signature | Description |
|---|---|---|
*Schema | (strict?: boolean) => ZodString | Validates 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.
Example
Section titled “Example”import { z } from 'zod'import { peselSchema, peselParseSchema } from '@slashlab/numerik-js/zod'
// Validate onlyconst formSchema = z.object({ pesel: peselSchema(),})
// Validate and transform to a Pesel value objectconst parseFormSchema = z.object({ pesel: peselParseSchema(),})
const result = parseFormSchema.parse({ pesel: '92060512186' })result.pesel.getBirthDate() // Date — 1992-06-05Use 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.