Coder Social home page Coder Social logo

Comments (9)

almet avatar almet commented on May 2, 2024

I'll let @n1k0 ponder, he's our local json-schema expert (if you ask him, he'll say he's not, but that's lies)

from react-jsonschema-form.

n1k0 avatar n1k0 commented on May 2, 2024

@almet Haha, hmpf, thanks I guess.

Yes, we need to deal with a specific kind of array widget when the schema is constrained with an enum of strings (possibly numbers, integers, datetimes too) so we can render a select field (or a list of checkbox btw) instead of the regular ArrayField.

The only thing is that with such a schema, one might want to allow multiple occurrences of an allowed enum value in the resulting array, eg. ["foo", "bar", "foo"]. Reading this thread from 2009 about just this is slightly worrying though, as I couldn't find any followup to this specific problem. Hope it's just me who can't search for things.

Also, re enumNames support, there's #25 issue filed already.

from react-jsonschema-form.

n1k0 avatar n1k0 commented on May 2, 2024

Actually while googling for solutions I've just stumbled upon the Choices v5 proposal, which is probably something we'll want to support if it makes it to the spec eventually.

from react-jsonschema-form.

n1k0 avatar n1k0 commented on May 2, 2024

And so for ensuring a multiple choices field can't be mistaken for a multiple occurrences of choices field, there's is that UniqueItems proposal.

Edit: uniqueItems seems already used in http://json-schema.org/example1.html. We can probably safely bet on it being widely supported, though we should definitely check with the validation lib we use.

from react-jsonschema-form.

cedricmessiant avatar cedricmessiant commented on May 2, 2024

Okay, so to sum up I can start working on supporting schemas like this :

myField: {
  type: 'array',
  title: 'My field',
  items: {
    enum: [
      'foo',
      'bar',
    ],
    type: 'string'
  },
  uniqueItems: true,
}

resulting on a multiple select (and maybe alternatively a list of checkboxes). Is that it ?

from react-jsonschema-form.

n1k0 avatar n1k0 commented on May 2, 2024

Is that it ?

That's a good summary of it, yes. Thanks you so much on planning to help and contribute!

from react-jsonschema-form.

cedricmessiant avatar cedricmessiant commented on May 2, 2024

I just finished the work on this issue. However, I can not push my branch upstream to make my pull request. Could you give me the rigths on the repo or do you prefer that I make my pull request from a fork ?

from react-jsonschema-form.

Natim avatar Natim commented on May 2, 2024

Yes please do it from a fork, you could also give us some contributors roles on your fork if you want us to collaborate on your branch.

from react-jsonschema-form.

n1k0 avatar n1k0 commented on May 2, 2024

Fixed by #42.

from react-jsonschema-form.

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.