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

validation error when using format property #837

Closed
1 task
locales-wellington opened this issue Feb 12, 2018 · 6 comments
Closed
1 task

validation error when using format property #837

locales-wellington opened this issue Feb 12, 2018 · 6 comments

Comments

@locales-wellington
Copy link

locales-wellington commented Feb 12, 2018

Prerequisites

  • [x ] I have read the documentation;
  • In the case of a bug report, I understand that providing a SSCCE example is tremendously useful to the maintainers.

Description

Introduction of ajv validation prevents form submission when using unknown 'format' property

Steps to Reproduce

https://jsfiddle.net/hdp1kgn6/1/

Add format: "textarea" to description and try and submit form

Expected behavior

I can add custom fields which will format ui based on format property in data and not prevent submission

eg.

description: {type: "string". format: "textarea"}
const fields = {
 customField: CustomFieldComponent
}
const uiFields = { desc: { 'ui:field': 'customField'  };

Actual behavior

Error on form submission (ajv validation)
Uncaught Error: unknown format "textarea" is used in schema at path "#/properties/description"

Version

1.0.x

You can usually get this information in your package.json or in the file URL if you're using the unpkg one.

@harouny harouny mentioned this issue Apr 11, 2018
9 tasks
@glasserc
Copy link
Contributor

What does format: "textarea" mean? It's not one of the formats in the JSON Schema spec. We should probably throw an error as soon as you put that in a schema.

@locales-wellington
Copy link
Author

7.2 "Implementations MAY add custom format attributes."
AJV allows the addition of custom formats https://github.com/epoberezkin/ajv#formats so it seems that it would be sensible to allow implementations using react-jsonschema-form to add these?

I am using ajv with react-jsonschema-form 0.51 and the 1.0.0 release breaks my implementation by not allowing that option.

@glasserc
Copy link
Contributor

You can already add widgets for any format you like as part of the registry.

@locales-wellington
Copy link
Author

But not custom formats in the schema correct? Because that will fail validation. For example: I have a schema that includes a format 'markup' for a string to display a markup editor. I should be able to add that custom format to the validator (ajv) so I don't get a validation error. The validator ajv that has been added provides that option so it seems odd that the react-schema-form api would not?

@glasserc
Copy link
Contributor

Yes, someone using rjsf should be able to interact with the ajv validator directly. See #783, #794.

@locales-wellington
Copy link
Author

Ah, righto - thanks :)

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

No branches or pull requests

2 participants