Code Monkey home page Code Monkey logo

Comments (6)

lucas-koehler avatar lucas-koehler commented on June 16, 2024

Hi @alxdru , thanks for the report :)
I have two questions:

  1. Which framework (e.g. react, angular, vue) and which renderer set did you use?
  2. Could you try this with the latest released version 3.2.1 to see if that fixes the issue?

Thanks!

from jsonforms.

alxdru avatar alxdru commented on June 16, 2024

Hi @lucas-koehler

  1. We're using react 18 and @jsonforms/material-renderers 3.1.0
  2. I've tried both 3.2.0 and 3.2.1, unfortunately no positive results.

from jsonforms.

alxdru avatar alxdru commented on June 16, 2024

We are still having this issue.
@lucas-koehler Have you reproduced the issue by any chance?

from jsonforms.

lucas-koehler avatar lucas-koehler commented on June 16, 2024

Hi @alxdru , I have tested this now in the react seed and I could reproduce the issue. I also contrasted the oneOf with a simple string property outside the oneOf and there a validation error was still shown even with validation mode NoValidation.

For reference for future investigations. I used the following in the jsonforms react seed with jsonforms 3.2.1

Schema
{
  "type": "object",
  "properties": {
    "addressOrUser": {
      "oneOf": [
        {
          "type": "object",
          "title": "Address",
          "properties": {
            "street_address": { "type": "string" },
            "city": { "type": "string" }
          },
          "required": ["street_address", "city"]
        },
        {
          "type": "object",
          "title": "User",
          "properties": {
            "name": { "type": "string" },
            "mail": { "type": "string" }
          },
          "required": ["name", "mail"]
        }
      ]
    },
    "plain-prop": {
      "type": "string"
    }
  },
  "required": ["plain-prop"]
}
Manual validation
import Ajv, { ErrorObject } from 'ajv';

// [...]
const [additionalErrors, setAdditionalErrors] = useState<ErrorObject[] | undefined>([]);
const ajv = new Ajv();
const validator = ajv.compile(schema);

// [...]
<JsonForms
  schema={schema as any}
  // uischema={uischema}
  data={data}
  renderers={renderers}
  cells={materialCells}
  onChange={({ errors, data }) => {
    setData(data);
    validator(data);
    setAdditionalErrors(validator.errors ?? undefined);
  }}
  additionalErrors={additionalErrors}
  validationMode='NoValidation'
/>

from jsonforms.

lucas-koehler avatar lucas-koehler commented on June 16, 2024

Hi @alxdru ,
I had a look again and noticed that I forgot that we need the AJV options allErrors. You can use convenience method createAjv from @jsonforms/core to get an Ajv with required options preconfigured. Using this, the validation in the oneOf also worked with NoValidation.
Can you check whether that works for you?

from jsonforms.

alxdru avatar alxdru commented on June 16, 2024

Thanks @lucas-koehler , using the createAjv did the trick.

Prior to this I was indeed passing allErrors: true to the ajv constructor, but I guess there were some other properties missing as well.

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.