Comments (4)
While those are very good workarounds, as part of the explanation I should've added that the forms are always dynamic and there's no control over the schema definition being used. I can't control how many oneOf constructs the forms would have
You can use the second workaround I posted and just always activate it whenever there is a oneOf with more than X entries in your retrieved schema. There really is no downside to that workaround besides the loss of validation for the oneOf. That validation is almost always meaningless anyway as the UI already makes sure that only a valid value is stored in the form data.
from jsonforms.
@sdirix
Hi Stefan,
Just coming back with updates, the workaround you proposed is a good solution.
We're only losing validation for the oneOfs that are too long, but it doesn't feel like a big loss.
Thank you!
from jsonforms.
As you noticed, the error comes from the validation framework Ajv we are using. See this open issue (ajv-validator/ajv#1705) for more details.
Thereโs not much we can do about that except for waiting for a fix. However there are some workarounds you can use:
- Restructure your schema to not use so many
oneOf
. Instead useenum
. If you used theoneOf
constructs to render different labels for your enums, you can use the JSON Forms i18n support instead to deliver alternative labels for the enums. Or, - Turn off validation within JSON Forms by handing over
validationMode="NoValidation"
. Then whenever you receive a data event from JSON Forms, you can validate it yourself outside. You can also useAJV
for this. Once validated, you hand over the determined errors via theadditionalErrors
prop back to JsonForms. The clue: You validate with a modified schema in which you removed the oneOf construct. You will lose the validation for that specific part, but all the remaining validations will work as before.
from jsonforms.
@sdirix Thanks for the quick response.
While those are very good workarounds, as part of the explanation I should've added that the forms are always dynamic and there's no control over the schema definition being used. I can't control how many oneOf
constructs the forms would have.
Just to put it out there, if it helps anybody else. I've tried to bypass the issue by using $ref
and dividing the long oneOf
list into multiple smaller size ones. It did render the form with validations in this case. Although, the UX of the form changes by having a couple of tabs to choose from for that particular dropdown.
from jsonforms.
Related Issues (20)
- deriveLabelForUISchemaElement() return undefined if no translation was found and no label defined HOT 3
- Issue with rendering validation errors for oneOf and anyOf HOT 6
- React MUI : MaterialEnumArrayRenderer - Add Form Label and description
- Date Picker doesn't work on mobile devices with material-renderers `v3.2.1` HOT 2
- jsonforms is not allowing null value for a key HOT 2
- default value set is not working in angular HOT 1
- Cannot clear field with default value HOT 2
- Vue allOf example crashes
- Angular material tablerenderer exceeds the width of JSON Forms
- Jsonforms Map Render Support in React HOT 4
- Get rid of lodash and swap it out for lodash-es HOT 6
- UI broken in the Documentation HOT 2
- uischema props are not propagated to Layout renderer when using a material Object Renderer HOT 1
- Typescript types not exported HOT 2
- ArrayLayoutRenderer was not found in '@jsonforms/angular-material' HOT 8
- Detect and restructure import cycles
- Data not be modify HOT 2
- Errors duplication while validating HOT 1
- Support 'dependentRequired'
- UpdateAction array context should also be handed over in the ExpandPanels [Material UI]
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jsonforms.