Code Monkey home page Code Monkey logo

Comments (4)

sdirix avatar sdirix commented on June 19, 2024 1

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.

alxdru avatar alxdru commented on June 19, 2024 1

@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.

sdirix avatar sdirix commented on June 19, 2024

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 use enum. If you used the oneOf 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 use AJV for this. Once validated, you hand over the determined errors via the additionalErrors 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.

alxdru avatar alxdru commented on June 19, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.