JS Use
mikila85 opened this issue · 5 comments
Is there a way to call the library with schema+data params and get a list of errors/required fields?
If you just need to validate your schema with formData look at https://github.com/tdegrunt/jsonschema, this is what react-jsonschema-form uses internally
Yes but the conditional required even when filled is the trick you guys solved.
@mavarazy, Yes I need a list of errors and required fields from schema+data.
Problem is, no schema validator will give you a list of required fields! They only give required error if the field is empty+required. But the *required marking should always be visible even if the field is full. And field can be conditionally required.
You guys solved it and know to mark a conditionally required field with "*required" marking.
@mikila85 If I understand the problem is following:
- You need a list of required fields from the schema
- Some of your fields are conditionally required, based on formData
- You want this project to give you accurate schema, based on the formData you have + original schema
If this is the problem you can get accurate schema, by calling rulesRunner
with appropriate formData and schema, and it should give you result schema with changed required field.
Project does not do required field validation it delegates this to react-jsonschema-form
, which supports this functionality out of the box. The way it works - is changing schema & uiSchema, that is used in react-jsonschema-form
, and effectively changing this behavior.
We do not have any specific functionality to get all required fields from the schema, if this is what you are after.