ConstNonNegativeIntegerSchema.parse(0); // ✓ Valid (zero)
NonNegativeIntegerSchema.parse(42); // ✓ Valid (positive integer)
NonNegativeIntegerSchema.parse(1000); // ✓ Valid (large positive integer)
NonNegativeIntegerSchema.parse(-1); // ✗ Throws validation error (negative)
NonNegativeIntegerSchema.parse(3.14); // ✗ Throws validation error (not integer)
NonNegativeIntegerSchema.parse(-3.14); // ✗ Throws validation error (negative and not integer)
NonNegativeIntegerSchema.parse('42'); // ✗ Throws validation error (string)
import { createAssertion, use } from 'bupkis';
import { NonNegativeIntegerSchema } from 'bupkis/schema';
const arrayIndexAssertion = createAssertion(
  [NonNegativeIntegerSchema, 'to be a valid array index'],
  NonNegativeIntegerSchema,
);
const { expect } = use([arrayIndexAssertion]);
expect(0, 'to be a valid array index'); // Valid array index
expect(5, 'to be a valid array index'); // Valid array index
A Zod schema that validates non-negative integer values.
This schema validates numbers that are both integers (whole numbers without decimal parts) and non-negative (greater than or equal to zero). It combines Zod's integer validation with non-negative validation to ensure the value is a valid count, index, or other non-negative discrete quantity.