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

Proposal: allow undeclared properties by default, but optionally disallow them #3

Open
davejhilton opened this issue Jun 4, 2018 · 0 comments
Labels
enhancement New feature or request

Comments

@davejhilton
Copy link

This is a two-part proposal to change the spec for JSTN validators.

Part 1 of the proposal
...is to allow JSON documents with additional undeclared properties to be considered valid by default, so long as all declared properties are valid according to the other validator conditions.

Essentially, this proposal is to remove condition #3 from the spec under the Validators section:

  1. No object properties exist in the JSON document that are not declared in the JSTN type declaration

The justification for the proposed change is to make life easier for APIs described by JSTN declaration when evolving over time. If JSTN validators were to allow undeclared properties to exist in the JSON document, then the transition path for an API that wants to add a property to its data becomes possible, without simultaneously updating all clients.

Part 2 of the proposal
... is to add a "Strict Mode" to the validator spec, which preserves the old (current) behavior.

The idea would be that validators would use the behavior described in part 1 of this proposal as their default implementation... but optionally also implement a "strict mode" validator, which disallows the presence of undeclared properties.

Check out my pull request #1 to see an example of this in action, as well as some proposed verbiage for the SPEC.md file to describe this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants