Nested jsonschemas are not validated

I am using a nested jsonschema for validation, eg. jsonforms-react-seed/schema.yaml at master · ioggstream/jsonforms-react-seed · GitHub

but nested properties seem not to be included in validation.

The jsonschema.core.errors array is empty when a required property of a nested schema is missing.

Any hint? Should I manually run a jsonschema validator to cover this use case?

[original thread by Roberto Polli]

Hi! I took a look at your provided example. First I wanted to say that I really like where your project is going. The form looks pretty neat, the markdown is a nice addition, and producing a pdf is pretty cool.

The validation for nested objects should work in general so a manual validation run should not be necessary. The problem here is that bollo is part of dichiarazione. dichiarazione is only properly validated by Ajv when it exists. In your example dichiarazione starts out as undefined which is why its content, including bollo is not properly validated. We need to check how to improve JSON Forms’ interaction with Ajv to also produce an error here. Maybe issue #1565 is related to this.

As a workaround you can change your initial data to include an empty object for dichiarazione in index.tsx.

const data = {
  richiedente: {
    given_name: 'Roberto',
    family_name: 'Polli',
  dichiarazione: {},

You can see in the screenshot that it then validates successfully.

Some more things that I noticed:

  • I would recommend using the standalone version of JSON Forms, not the Redux variant. You can just remove all the Redux code and pass in your custom renderer and refParser configuration into the standalone JsonForms component, just avoid creating a “data circle”, e.g. when listening on data changes from JSON Forms don’t feed the data back into JSON Forms. We’re slowly facing out the Redux variant as we want to remove this forced dependency on all consumers of JSON Forms. If you want you can also wait for this as I want to update the React seed soonish (probably next month) to focus more on the standalone approach.

  • You can use options: {trim: true} on all controls which should not take the full width. I exemplary added it to the bollo control as you can see in the screenshot.

  • You can remove the __filemeta object at the end of the schema.yaml. This is just a bad artifact in the example which we want to clean up at some point.

  • You can remove the - dichiarazione/bollo in line 5 of the schema.yaml. The JSON Schema specification doesn’t allow to specify nested properties there in the required field.

  • If you want default values to be auto-filled into your data when rendering JSON Forms you can configure Ajv to do it.

Let me know when you have further questions :slight_smile:

[Roberto Polli]

Thank you very much: that works :slight_smile:

1- ok to remove _filemeta
2- ok for schema.yaml:5 I tried that to trick jsonforms :smiley:
3- I’ll pass the Redux note to a colleague which is more acquainted with the subject.
4- thx for trim