-
Notifications
You must be signed in to change notification settings - Fork 373
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
(core, testers) allow other additional types besides 'string' when testing for format #1925
(core, testers) allow other additional types besides 'string' when testing for format #1925
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @jdwit,
Thank you for the PR ❤️ ! In general this make a lot of sense. However there are some considerations.
Changing the behavior of formatIs
is a breaking change. Not every developer using it might be expecting null
(or even completely arbitrary) values in their renderer, potentially leading to runtime crashes. As we're shortly before the 3.0 release this is a good opportunity to change this, but we need to add an entry to the migration guide. Please add this to the PR.
In then same vain we need to test all our renderers which use formatIs
(React Material, React Vanilla, Angular Material, Vue Vanilla, Vue Vuetify) whether they can handle arbitrary value types. Can you help with this endeavor?
Thinking about this some more: We should probably adapt Additionally when the What do you think? Is this the same use case you have? |
Hi @sdirix , I can help providing the test coverage and adding an entry to the migration guide. Interesting point you make on the limitation of only However this is not really compatible with the concept of selecting a renderer (which must represents a single type/format) 😄 . Considering this your suggestion of only allowing The thing you mentioned about null being the value when field is cleared, if null is in the collection of allowed types is exactly my use case, I am going to add this to must custom bindings set, thanks. I am not sure if this should be part of the JSONForms core however. |
Hi @jdwit, I'm fine with merging this as is in case the format renderers can handle problems relatively gracefully. The null handling should probably be done in a follow up later on. Did you have a chance to test them? |
I came across an issue where I have the following schema:
As far as I know this is valid JSON schema, and is not really an edge case: a date field might be allowed a NULL value (maybe I am wrong here).
Currently the
isDateControl
andisDateTimeControl
do not work here because theyformatIs
tests forschema.type === 'string'
. This is replaced withhasType(schema, 'string')
so the format is recognized correctly when other types are allowed (such as null) as well.