JSON Schema Validation/Basic object schema

Require a string name and boolean active flag.

Section: Schema basics

Basic object schema

json
json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "name": { "type": "string" },
    "active": { "type": "boolean" }
  },
  "required": ["name", "active"],
  "additionalProperties": false
}
Explanation

A good baseline for validating a small payload shape.

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing Schema basics
Enum restriction
Restrict a value to a known set of strings.
OpenIn sheetjsonsame section
Array item validation
Validate every item in an array.
OpenIn sheetjsonsame section
Validate with Ajv CLI
Validate a JSON file against a schema file.
OpenIn sheetbash2 tag match
Validate multiple files with Ajv
Validate a whole set of JSON documents.
OpenIn sheetbash2 tag match