I am in search of a solution to extract the required fields from a JSON Schema and Data combination.
Currently, we are utilizing AJV for getting error messages in our forms using JSON Schema, and it has been performing really well.
I am looking for a method to retrieve all the required fields (even if already filled) so that I can label those fields with * as "required". The required fields may vary depending on the schema and data combinations.
I also attempted to extract the required fields using tv4, but without success.
Your assistance would be greatly appreciated.
Here is an example of such a schema:
{
"type": "object",
"required": [
"checkbox"
],
"properties": {
"checkbox": {
"type": "boolean"
},
"textbox": {
"type": "string"
}
},
"oneOf": [
{
"required": [
"textbox"
],
"properties": {
"checkbox": {
"enum": [
true
]
}
}
},
{
"properties": {
"checkbox": {
"enum": [
false
]
}
}
}
],
"additionalProperties": false
}