JSON Schema Validation/Enum restriction

Restrict a value to a known set of strings.

Section: Schema basics

Enum restriction

json
json
{
  "type": "object",
  "properties": {
    "status": {
      "type": "string",
      "enum": ["draft", "published", "archived"]
    }
  },
  "required": ["status"]
}
Explanation

Enums are useful for states, roles, and constrained option lists.

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
Basic object schema
Require a string name and boolean active flag.
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