Skip to content
github-actions[bot] edited this page Oct 29, 2026 · 3 revisions

PVL wiki

PVL (Precompiled Validation Library) validates values against schemas you describe in TypeScript. A schema works in two ways:

  • Interpreted: @pcvl/schema walks the schema at runtime. Each schema object runs its own steps in order and calls the schemas nested in it.
  • Compiled: @pcvl/compiler reads the schema from your source ahead of time and writes plain if/for code that does the same checks, with nothing left to walk at runtime.

Both ways accept and reject the same values, report the same Issues, and type the same. These pages show, with a graph for each, how every schema works in both.

flowchart LR
    S["pvl.string().min(3)"] --> I["Interpreted: a schema object<br/>runs its steps at runtime"]
    S --> C["pvl compile: the compiler<br/>writes the checks out as code"]
    I --> R["Result: { value } or { issues }"]
    C --> R
Loading

Start with Concepts if a term is new to you.

How validation works

Page What it shows
Interpreted pipeline How every interpreted schema runs its Modifiers around its type check
Compiler build pipeline What pvl compile does, from the config file to the written Destination Directory
Compiled schema runtime The shape every Compiled Schema shares, and how its emitted _validate runs

Shared Modifiers

Every schema has these five. Each page shows the Modifier interpreted and compiled.

  • Optional: .optional() accepts undefined
  • Nullable: .nullable() accepts null
  • Coerce: .coerce() converts the input before the type check
  • Refine: .refine() adds your own check
  • Transform: .transform() turns the accepted value into another one

Schemas

Schema Accepts Compiles?
String a string yes
Number a number that isn't NaN yes
BigInt a bigint yes
Boolean true or false yes
Literal exactly one value yes
Enum one of a set of strings and numbers yes
Object an object whose fields match their schemas yes
Array an array whose elements match one schema yes
Union a value one of several schemas accepts not yet

Clone this wiki locally