Panther schemas: does the "required" flag propagate to subfields as well?
Last updated: September 3, 2024
QUESTION
If I have a required field in my schema that's of type object, will the subfields of the object be required by default too?
ANSWER
No, if you have an object field, the subfields are all optional by default, regardless of whether the object field is required or not. For a subfield to be required, you need to explicitly mark it as such. In the example below, myObj.foo is an optional field, but myObj.bar is required.
fields:
- name: myObj
type: object
required: true
fields:
- name: foo
type: string
- name: bar
type: bigint
required: true