Map
Example
Section titled “Example”import * as p from '@vbudovski/paseri';
const schema = p.map(p.number(), p.string());const data = new Map([[1, 'foo'], [2, 'bar'], [3, 'baz']]);
const result = schema.safeParse(data);if (result.ok) { // result.value typed as `Map<number, string>`.}
Playground
Section titled “Playground”Validators
Section titled “Validators”Consists of at least size
elements.
p.map(p.number(), p.string()).min(3);
Consists of at most size
elements.
p.map(p.number(), p.string()).max(3);
length
Section titled “length”Consists of exactly size
elements.
p.map(p.number(), p.string()).size(3);