Primate LogoPrimate

Built-in values

These schemas validate Web and JavaScript built-in objects. For strings, URLs and UUIDs, see Strings.

Booleans

p.boolean accepts only true or false. The loose form also accepts the boolish strings "true" and "false":

p.loose.boolean.parse("true"); // true

The returned BooleanType is Storable with datatype boolean.

Dates

p.date accepts any Date instance. It does not currently reject a Date whose timestamp is NaN. p.loose.date additionally converts:

p.loose.date.parse("2026-10-11");
// 2026-10-11T00:00:00.000Z

Use p.date.now() for a fresh current-time default when the input is missing:

const Event = p({
  created_at: p.date.now(),
});

This is shorthand for p.date.default(() => new Date()). It creates the date when the default is applied; it does not automatically update the value later.

Timezone-free datetime strings are not coerced. DateType is Storable as datetime.

Blobs and files

p.blob validates Blob instances and p.file validates File instances. Both map to the persistent blob datatype, while preserving their distinct runtime output types.

const payload = p.blob.parse(await request.body.blob());

BlobType and the file schema currently provide type validation plus the common optional(), default() and derive() wrappers. They do not provide size or MIME-type methods; express application-specific restrictions outside the schema or through a dedicated schema when such an API is added.

For structured values stored in a JSON field, use p.json().