Skip to content
JSON

Schema Validation

Validate structure with JSON Schema.

By EZ4Code Team
schemavalidation

Code

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "name": { "type": "string", "minLength": 1 },
    "age": { "type": "integer", "minimum": 0 },
    "email": { "type": "string", "format": "email" }
  },
  "required": ["name", "email"],
  "additionalProperties": false
}

Explanation

JSON Schema describes the expected shape of a JSON document so validators can check types, ranges, required fields, and formats. The $schema keyword pins the draft version, and additionalProperties:false forbids unexpected keys. Validators like Ajv compile schemas for fast repeated checks.

More JSON Snippets