Validate JSON data with schemas, types, required fields, formats, composition, and API contracts.
Lessons
Turn schema validation failures into useful UI and API messages.
Human-Friendly Validation Errors is easiest to learn by reading the example, changing it, and observing the result.
// Ajv error objects map cleanly to API/UI messages
const errors = validate.errors.map(e => ({
field: e.instancePath.replace(/^\//, '') || e.params.missingProperty || '(root)',
message: e.message
}));
console.log(errors);
// [ { field: 'title', message: 'must NOT have fewer than 3 characters' } ]Practice the Human-Friendly Validation Errors example in a small scratch file, then explain what changed and why.