Validation Schema

noun

say it: “val-ih-DAY-shun SKEE-muh” /ˌvæləˈdeɪʃən ˈskimə/

A written description of what valid data looks like, field by field, that a program checks incoming data against.

What is a validation schema?

A validation schema describes the shape data must have: its fields, what kind of value each holds, and its limits. A library such as Zod checks values against it, so the rules live in one place.

const Student = z.object({
  name: z.string().min(1),
  grade: z.number().int().min(1).max(12),
});

In a sentence

  • “When the rules changed, Sam edited the validation schema once instead of five if statements.”
  • “The validation schema says a student's grade is a whole number from 1 to 12.”

Level: Apprentice · More JavaScript terms at this level

Updated