Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add schemaPath to errors object in transformErrors #1140

Closed
wants to merge 44 commits into from

Conversation

epicfaace
Copy link
Member

Reasons for making this change

Fixes #838 by exposing schemaPath in the items in the errors list.
Also documents the objects in the errors list to fix #818 .

If this is related to existing tickets, include links to them as well.

Checklist

  • I'm updating documentation
    • I've checked the rendering of the Markdown text I've added
    • If I'm adding a new section, I've updated the Table of Content
  • I'm adding or updating code
    • I've added and/or updated tests
    • I've updated docs if needed
    • I've run npm run cs-format on my branch to conform my code to prettier coding style
  • I'm adding a new feature
    • I've updated the playground with an example use of the feature

@epicfaace
Copy link
Member Author

I'm getting this test failure, not sure why


  1) Validation
       validate.validateFormData()
         Invalid schema
           should return an error list:
      AssertionError: expected '#/definitions/stringArray/type' to deeply equal '#/properties/foo/required'
      + expected - actual
      -#/definitions/stringArray/type
      +#/properties/foo/required
      
      at Context.<anonymous> (test/validate_test.js:216:38)

epicfaace and others added 24 commits January 20, 2019 16:22
rjsf-team#1142)

* rjsf-team#556 - handle recursive references to deep schema definitions

* test: add tests for recursive references

* fix: handle multiple recursive references to deep schema definitions
…jsf-team#1131)

* Add test and update documentation for using anyOf inside array items

Signed-off-by: Lucian <lucian.buzzo@gmail.com>
…am#1143)

* fix: add onBlur and onFocus events for radio and checkbox widgets

* fix: use event.target.checked instead of event.target.value for checkbox
…eam#1129)

This change improves the logic that selects a matching anyOf branch
based on form data. Previously the behaviour was to just check if the
form data was valid against an anyOf branch, however due to the
permissive nature of JSON schema this has unexpected behaviour. For
example, given the following schema:

```json
{
  "type": "object",
  "anyOf": [
    {
      "properties": {
        "foo": {
          "type": "string"
        }
      }
    },
    {
      "properties": {
        "bar": {
          "type": "string"
        }
      }
    }
  ]
}
```

The form data `{ bar: 'baz' }` will actually match the first branch. To
mitigate this, when doing the matching, the branch schema is augmented
to require at least one of the keys in the branch. For example the
schema above would become:

```json
{
  "type": "object",
  "anyOf": [
    {
      "properties": {
        "foo": {
          "type": "string"
        }
      },
      "anyOf": [
        { "required": [ "foo" ] }
      ]
    },
    {
      "properties": {
        "bar": {
          "type": "string"
        }
      },
      "anyOf": [
        { "required": [ "bar" ] }
      ]
    }
  ]
}
```

Signed-off-by: Lucian <lucian.buzzo@gmail.com>
* Fixes rjsf-team#824

* Added test

* Separated tests
* fix: uiSchema for additionalProperties rjsf-team#1132

* doc: update readme

* doc: fix toc

* doc: update docs
@glasserc
Copy link
Contributor

glasserc commented Feb 4, 2019

I guess it's because ajv defines required using $ref: "#/definitions/stringArray". See e.g. https://github.com/epoberezkin/ajv/blob/0020556493f3d443002596697768f3f047782198/lib/refs/json-schema-draft-07.json#L110. I guess ajv reresolves the value against the $ref'd schema. Check out ajv-validator/ajv#512 and especially ajv-validator/ajv#876. I'm not sure what to do here... we could expose schemaPath with a note that it might be wrong?

glasserc and others added 13 commits February 4, 2019 14:22
This change adds support for schemas that use the `const` keyword
without and adjacent `type` keyword. For example:

```json
{
  "type": "object",
  "properties": {
    "firstName": {
      "const": "Chuck"
    }
  }
}
```

Signed-off-by: Lucian <lucian.buzzo@gmail.com>
…eam#1171)

Change-type: patch
Signed-off-by: Lucian <lucian.buzzo@gmail.com>
Change-type: patch
Signed-off-by: Lucian <lucian.buzzo@gmail.com>
…jsf-team#1169)

* Fix multiple bugs related to switching between anyOf/oneOf options

Fixes rjsf-team#1168

- Fixed a bug that would prevent input fields from rendering when
switching between a non-object type option and an object type option
- Fixed a bug where options would incorrectly change when entering
values if a subschema with multiple required fields is used
- Fixed a bug where switching from an object tpye option to a non-object
type option would result in an input field containing the value [Object object]

Change-type: patch
Signed-off-by: Lucian <lucian.buzzo@gmail.com>

* Update src/utils.js

* Update src/utils.js
Followup to f62cfc4 which broke the build:readme script
README.md Outdated Show resolved Hide resolved
test/validate_test.js Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add schemaPath to transformAjvErrors Inconsistent syntax for property paths in error objects
8 participants