7

Im trying to use json-schema validation at some project, and want to ask about the "required" field.

In current doc there is a specifiaction:

The value of this keyword MUST be an array. This array MUST have at least one element. Elements of this array MUST be strings, and MUST be unique.

But in another examples in the web, i can find something like:

"properties": {
    "foo": {
        "required": true
    }
}

What is a valid way to define required fields?

GreenAsJade
  • 14,459
  • 11
  • 63
  • 98
Sergey Kamardin
  • 1,640
  • 1
  • 18
  • 22

1 Answers1

15

In version 3 of JSON Schema it was a boolean. In the latest version, 4, it is now an array of strings. The validator you are using may still be implementing the old specification.

Daniel Coupal
  • 815
  • 6
  • 8