Documentation index
Russian translation
This guide summarizes the package surface of @modulify/validator and its supported subpath exports.
It is meant as a navigation document:
- where each public entrypoint lives;
- which groups of functions are exported together;
- what the validation result looks like;
- which APIs belong to dedicated subpaths such as predicates and JSON Schema export.
The root package exports:
validatevalidate.syncmatches.syncmetadescribecustomcollectionViolationCollection- all exports from
./assertions - all exports from
./combinators
Use the root package when you need the main validation API, composed validators, metadata/introspection, and violation utilities.
The root package includes:
- low-level assertion construction through
assert(...) - built-in assertions such as
isString,isNumber,isBoolean,isNull,isEmail,hasLength(...),oneOf(...) - structural combinators such as
shape(...),each(...),tuple(...),record(...) - wrapper combinators such as
optional(...),nullable(...),nullish(...) - branching combinators such as
union(...)anddiscriminatedUnion(...) - exact-value matching through
exact(...)
This is the main runtime-facing API surface of the library.
The same root package also includes:
meta(...)describe(...)custom(...)
Together these provide the public machine-readable descriptor contract and the metadata layer built on top of it.
The root package also includes:
- raw violation results returned by
validate(...) collection(...)ViolationCollection
These are the main utilities for post-processing machine-readable validation failures.
validate(...) and validate.sync(...) return:
type ValidationTuple<T> =
| [ok: true, validated: T, violations: []]
| [ok: false, validated: unknown, violations: Violation[]]Practical meaning:
oktells whether validation succeeded;validatedbecomes strongly typed only in the success branch;violationsis empty on success and contains structured failures on error.
Predicates are available from:
@modulify/validator/predicatesThis subpath contains reusable runtime/type-guard helpers and predicate combinators such as:
isStringisNumberisRecordisArrayisShapeAnd,Or,Not
Use this subpath when you want guard-style runtime checks without pulling in the higher-level validation layer.
JSON Schema export is available from:
@modulify/validator/json-schemaThis subpath contains:
toJsonSchema(...)JsonSchemaExportError
It is intentionally kept separate from the root package so that export-specific concerns stay isolated from the main validation entrypoint.
At a high level:
- root package = validation, combinators, metadata, violations;
./predicates= standalone runtime/type-guard helpers;./json-schema= derived JSON Schema export layer.
This split keeps the main API discoverable while still allowing specialized subpaths where needed.