Overview
Structural validators check whether an object, record, or tuple conforms to a specific shape, ensuring all required properties exist and meet their type constraints. They return a structured ValidationResult<T>, never throw exceptions, and never mutate the input object.
- validateArray: Ensures a value is an array (Array.isArray), rejecting objects, functions, and primitives.
- validateNonEmptyArray: Ensures a value is an array with at least one element, rejecting empty arrays and non-arrays.
- validateNonEmptyRecord: Ensures a value is a non‑null object with at least one own enumerable key, rejecting empty objects, arrays, and non-objects.
- validateObject: Ensures a value is a non‑null object, accepting all object types except arrays and functions.
- validatePlainObject: Ensures a value is a plain object whose prototype is exactly
Object.prototype. - validateRecord: Ensures a value is a non‑null, non‑array object whose own keys are strings, regardless of prototype.
- validateTuple: Ensures a value is an array of fixed length where each element satisfies a corresponding guard.
All structural validators are pure, predictable, and designed to compose efficiently, allowing you to validate complex nested data schemas without boilerplate.