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 transform hook for changing errors from json schema validation #432

Merged
merged 4 commits into from
Jan 23, 2017

Conversation

jbalboni
Copy link
Contributor

@jbalboni jbalboni commented Dec 22, 2016

Reasons for making this change

The error messages that come from the json schema spec/library (not sure where they come from) aren't very user friendly. They also clash with a pattern that the forms I work have for required validation, namely that those required errors should show up at the field level (rather than at the containing object).

One way of addressing those issues is to allow users to modify the error list sent back by the jsonschema library. Since that has all the error detail produced beyond just a message, it's easy to modify or write your own messages. This PR adds that hook.

I'm skipping updating tests and docs until I get some feedback on whether this is a good approach and something that this library should accommodate.

Thanks!

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'm adding a new feature
    • I've updated the playground with an example use of the feature

@n1k0
Copy link
Collaborator

n1k0 commented Jan 17, 2017

This is actually smart, I like it. Sure I'd love if the jsonschema lib we use exposed a better API, but I think this nicely solves our current needs with this issue.

Could you please rebase your patch against latest master, and add a few tests and docs? Sorry for being so late to provide feedback.

Copy link
Collaborator

@n1k0 n1k0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thanks!

@n1k0 n1k0 merged commit 74c6ec0 into rjsf-team:master Jan 23, 2017
n1k0 added a commit that referenced this pull request Jan 28, 2017
Breaking changes

When a text input is emptied by the user, it's value is now reset to `undefined` instead of being set to `""` (empty string) as previously. This better matches traditional HTML forms behavior.

New features

* Add an array field template component (#437)
* Wrap radio and checkbox labels into span to enable styling. (#428)
* Reset text inputs value when emptied (#442)
* Add transform hook for changing errors from json schema validation (#432)
* Add a noHtml5Validate prop (#448)
* Add support for a onBlur event handler (#431)
* Allow empty option for enum fields (#451)

Bugfixes

* Fix #452: Support recursively referenced definitions. (#453)
* Fix #454: Document what master actually is, suffix its version with -dev.
@n1k0
Copy link
Collaborator

n1k0 commented Jan 28, 2017

Released in v0.42.0.

@olzraiti olzraiti mentioned this pull request Jan 30, 2017
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.

None yet

2 participants