ConstPrimitiveSchema.parse('hello'); // ✓ Valid (string)
PrimitiveSchema.parse(42); // ✓ Valid (number)
PrimitiveSchema.parse(true); // ✓ Valid (boolean)
PrimitiveSchema.parse(BigInt(123)); // ✓ Valid (bigint)
PrimitiveSchema.parse(Symbol('test')); // ✓ Valid (symbol)
PrimitiveSchema.parse(null); // ✓ Valid (null)
PrimitiveSchema.parse(undefined); // ✓ Valid (undefined)
PrimitiveSchema.parse({}); // ✗ Throws validation error (object)
PrimitiveSchema.parse([]); // ✗ Throws validation error (array)
PrimitiveSchema.parse(() => {}); // ✗ Throws validation error (function)
import { createAssertion, use } from 'bupkis';
import { PrimitiveSchema } from 'bupkis/schema';
const primitiveAssertion = createAssertion(
  ['to be a primitive, Date, or RegExp'],
  PrimitiveSchema.or(z.instanceof(Date)).or(z.instanceof(RegExp)),
);
const { expect } = use([primitiveAssertion]);
expect('pants', 'to be a primitive, Date, or RegExp');
A Zod schema that validates primitive JavaScript values.
This schema validates any of the seven primitive data types in JavaScript: string, number, boolean, bigint, symbol, null, and undefined. Primitive values are immutable and are passed by value rather than by reference, distinguishing them from objects and functions which are non-primitive reference types.