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

Form Field type null #39

Open
niklase opened this issue May 25, 2018 · 2 comments
Open

Form Field type null #39

niklase opened this issue May 25, 2018 · 2 comments

Comments

@niklase
Copy link

niklase commented May 25, 2018

I would like to be able to specify form for deleting fields according to JSON Merge Patch (RFC7396) where field to be deleted when calling PATCH must have value null. A type (”type”:”null”) which only allows null as value would be a good way to express this. Or is there a better way to express a field which has to be null?

@lhazlewood
Copy link
Member

@niklase why not have a form that has as a member the names of fields to delete as a string array?

Just curious.

IMO a null type doesn't make sense - null isn't a type (I understand you're using it to indicate a special scenario but that feels like more of a workaround rather than a canonical solution).

@niklase
Copy link
Author

niklase commented May 29, 2018

APIs with updates according to JSON Merge Patch when doing HTTP PATCH will handle null values as delete of that field. In my API I have extended the Ion form field with a form field member "mustBeNull" which can be true or false (with false as default) and it works well to express the body to patch with but is not very pretty. You are right this is a special scenario but I prefer using standards like JSON Merge Patch rather than invent my own protocol for patching JSON data.

The reason I suggested a new type "null" is that it would fit into the spec without introducing any new form field member (like my "mustBeNull" extension) and if I look in the JSON spec (ECMA-404), the only "types" mentioned are string, number, object and array - and null is defined on exactly the same level (as is true and false).

I think it is good if it is possible to define an Ion form which is compliant with JSON Merge Patch. To do this I have to be able to tell the client that a value is required to be set to null when submitting the form.

I will stick with the API as I have it is for now but according to the draft spec it would be ok to add the type "null" even though it is not part of the spec and might not be recognized by the client. Is this correct?

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