-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Initial implementation of nullable type #329
Conversation
I really appreciate the amount of work done here. Though, I'm still trying to figure out the benefits of json nullable types in general, and am challenging our willing to support them in this form lib. It really seems to me that they try to mimic the I suspect there's a bunch of tools relying on them (I've seen people mentioning .Net in issues), but I'm still wondering if we really want to support these very specific, exotic-to-us use cases; this library was never supposed to cover the entire scope of jsonschema, especially its corner cases. The issue I have with landing code specific to certain existing tooling is that we (at Mozilla) don't use it, and we're not really prone to maintain something we don't use. But maybe I'm missing something obvious, and there's a valid use case for nullable types in jsonschema, which can't be achieved with a required field? On the other hand, I see value in providing a button to clear any entered value for non-required field, so we would drop it from the resulting formData. Would that be an acceptable solution to you, or would you need actual support for nullable types because you critically depend on them? |
We'd like to prevent the library from growing too much (if it's not too late already). Would it be possible to add only the necessary hooks here and leave the What do you think ? |
You might want to see issue #402 (comment) The last one is mine. I'm an advocate of turning "empty string" and "empty array" into undefined. This allows them to pass or fail validation when setting the "required" field. I personally plan to treat them as NULL in my backend and effectively disallow empty string (no loss for me). Just throwing this out there in case it meets your requirements without adding a new nullable type :) The array part of the patch has been submitted as a PR: The string part is referenced in my issue here: #410 Hope that helps! |
I agree with @n1k0 that I don't really see the value of having |
No activity since last September, I'm closing this. Feel anyone free to reopen if you're planning to work on this. |
I've been looking for a solution to this as I do have a use case for it. It may be too specific to be worth it but the short of it is that at least for our use case, there is a behavior difference between a value not being present in an API payload and a value that is being explicitly cleared or unset. The details: I have an object with several integer properties that I want to update via an API call. For an update operation, all properties are optional; anything that is not provided as part of the API payload remains unchanged. Of course, a property set to a certain integer in the payload would change the value. In addition, though, I need to be able to 'unset' or clear any of these properties, so I need a way of expressing this via JSON. In my opinion, using So the behavior is something like this: Payload Payload Payload So, I'd like my JSON schema to have As far as I can tell this use case can't be addressed with the required field of JSON schema. |
Addresses #282
Note: I had issues implementing HOC for nullable types, it was forcing loss of focus in inputs. Therefore, I used down and dirty Parent -> Child solution to implement nullable type.