Comments (15)
The world is small... Just come here to ask the same question. Support for oneOf
would be nice.
from react-jsonschema-form.
I've created #417 which deals with anyOf. The logic is built into ArrayField
, rather than the playground. It has some limitations, but for most of the cases it seems to be working. I am very interested in oneOf functionality as well, it is probably what I am going to work on next, unless I see someone else making some progress with it.
from react-jsonschema-form.
@travisdahl I'm not working on anything currently - In theory, to implement allOf
we would simple merge in the allOf
values into a single cohesive schema and then render it.
You could do this now with https://www.npmjs.com/package/json-schema-merge-allof (which I see you suggest in your comment here #1237 (comment)).
What do you think of using this package to merge in allOf
statements as part of RJSF?
from react-jsonschema-form.
I've spent the last few weeks working on this, see:
- #1118 for the implementation of
anyOf
- #1133 for
oneOf
support - #1131 for clarification around
anyOf/oneOf
in arrays
from react-jsonschema-form.
@n1k0 #302 It's just a custom component and not integrated into the ArrayField component unfortunately. I just wanted to slap something together to be able to play around with the UI.
from react-jsonschema-form.
@epicfaace Good catch, I just checked and we still need to add support for allOf
. It should be straightforward given the work already done.
from react-jsonschema-form.
I guess anyOf
might be harder to support as it essentially supports multiple input types. Maybe it'd also help to explain our use case. We have 2 schemas, one is only required for the insertion of a new record. So we validate the update call against the base schema, and then we're trying to merge the two schemas together for the insert form. In the example above schema2
essentially defines additional requirements on the base object schema.
from react-jsonschema-form.
I built a simple prototype for a custom field that supports oneOf
for an array, which relevant to my particular use case. Here's a quick demo. One of the difficulties I ran into was that validation didn't work how I wanted it to. I wanted each field to be validated against its own schema (e.g. a number field needed to have a number, not a string), but the whole array was validated against the oneOf
, so typing a string into a number field passed validation since one of the allowed schemas was a string. There may not be an easy way around this since the data is valid against the schema. Note that this is less of an issue if the oneOf
schemas are more complex, making it less likely that an invalid state for one of the schemas is a valid state for another.
I just wanted to offer up my prototype for discussion. Is this the kind of UI people had in mind? Generating a UI for oneOf
makes sense to me, and I think this same kind of UI would work for anyOf
, but it's much less clear what the UI should look like for allOf
. How else could oneOf
and anyOf
be used in a schema, and would the UI look particularly different than my prototype?
from react-jsonschema-form.
Wow that looks great :) Would you mind opening a PR so we can stare at code? I'm suspecting a lot of hidden edge cases but that may just be me being paranoid :)
from react-jsonschema-form.
It's great to see progress on this! 👍
from react-jsonschema-form.
I'm just dropping in from the JSON Schema spec project and noticed this. I'm aware that UI schema != Validation schema, but the array form of the items
keyword was designed exactly for this use case. If I understand the use case correctly. Is there a particular reason it was not considered?
from react-jsonschema-form.
This functionality is now available as of v1.2.1
from react-jsonschema-form.
@LucianBuzzo just making sure, we do support everything needed for allOf
, correct?
from react-jsonschema-form.
@LucianBuzzo are you currently working on a PR for allOf
?
from react-jsonschema-form.
@LucianBuzzo thats exactly what I ended up doing in my project to get around it.
see comment...
#1237 (comment)
from react-jsonschema-form.
Related Issues (20)
- DOCUMENTATION Issue: Wrong method signature? HOT 1
- Schema defines standalone checkbox as mandatory, but asterisk is not rendered. HOT 2
- I would like to make a default change to the look of all input fields HOT 5
- Adding required field in nested if/then/else not working correctly HOT 2
- FormData is not received based on schema properties HOT 1
- Select bug when multiple oneOf are nested HOT 2
- How can I cite this? HOT 6
- RJSF anyOf customization HOT 3
- Validation error when multiple $ref references point to a single definition HOT 3
- not working about validation HOT 3
- Passing ui options down to array items HOT 3
- MUI number input label UI issue with non-numeric input HOT 1
- Publish v6 release candidate with support for Bootstrap 5 HOT 1
- Can not replace "integer" widget HOT 4
- Omit Extra Data not behaving as expected on submit for allOf (if then) schemas along with additionalProperties set to false blocking form submission HOT 1
- `anyOf` form validation error messages confusing when `anyOf` items contain properties found in other items HOT 4
- How to reference an array field from an enum field?
- Array Length dependant on FormContext Value
- Add support for tremor UI library
- Issue with data of files array when we have validation required and minItems HOT 1
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 react-jsonschema-form.