Skip to content

Set

Example

import * as p from '@vbudovski/paseri';
const schema = p.set(p.number());
const data = new Set([1, 2, 3]);
const result = schema.safeParse(data);
if (result.ok) {
// result.value typed as `Set<number>`.
}

Playground

Schema
Data
Result

Validators

min

Consists of at least size elements.

p.set(p.number()).min(3);

max

Consists of at most size elements.

p.set(p.number()).max(3);

length

Consists of exactly size elements.

p.set(p.number()).size(3);