primate icon indicating copy to clipboard operation
primate copied to clipboard

create `@primate/pema` and deprecate `@primate/types`

Open terrablue opened this issue 1 year ago • 1 comments

General purpose validation module.

import schema from "@primate/pema";
import array from "@primate/pema/array";
import file from "@primate/pema/file";
import number from "@primate/pema/number";
import string from "@primate/pema/string";

// options:
// strict: do not coerce string values
const form = schema({
  id: number,
  title: string,
  tags: array(string).min(2),
  content: file,
}, { strict: true });

form.validate({ id: "1", title: "foobar" });
// -> success: returns validated fields, coerced to correct type if not strict
// -> failure: throws, with validation errors

terrablue avatar Jul 25 '24 19:07 terrablue

renamed in a31b9a3, schema validation itself pending

terrablue avatar Aug 24 '24 11:08 terrablue

17beb71

terrablue avatar Jun 30 '25 21:06 terrablue