there is no UI schema. I have a custom attribute “showProp” in each of the properties. I am using ajv validation. I have a custom control renderer, and in that i am checking schema.showProp to show or hide/return null for the control. This works fine. But since prop2 is required and its hidden due to the logic in the custom renderer, I get an validation error. Is there any way to handle this so that no errors are thrown and the control is also hidden?
The easiest way would be to use a JSON Schema which corresponds to the data which you want to handle. If a property shall not be shown and shall also not be validated, then I would recommend to remove it from the JSON Schema altogether before handing it to JSON Forms.
Alternatively you need to manually filter the errors via a middleware.
I have written my own validation logic using ajv in the onchange event and using that to display errors.How do I send the custom validation errors back to JsonForms from the custom renderer in the onChange event instead of JsonForm validating it?
I don’t fully understand. If you have a custom ajv instance, then you can just hand it over to JSON Forms via the ajv prop and it will be used for validation.
If that is not the use case, then:
In case you are validating outside of JSON Forms and want to hand in the errors for display, then you can use the additionalErrors prop which takes an array of errors in the AJV format. You probably want to also set validationMode: 'NoValidation' then.
In case you perform the custom validation within your renderer, then you either handle it locally there or collect them outside of JSON Forms. See here for a similar question.
I tried using a UI schema with only controls that I wanted to show based on certain conditions as mentioned in my earlier post.My UI scheam has the prop1 alone and does not include prop2. prop2 is required but not rendered using the uischema. I see that the json forms error object is having the prop2 as required. Is this the expected behavior?
to your question Stefan,
I am using a custom text field renderer. I am manually checking for empty strings here in the onChange event and providing a custom error message.I am also passing an ajv instance to JsonForms. I am also doing validate schema to get all the errors here. Now, if I say NoValidations as validationmode in JsonForms , I am able to view the errors displayed on screen using my custom error logic , but how do I pass these errors back to JsonForms in the Onchange event handler of JsonForms to be used in the parent component?