8000 Proposal: allow undeclared properties by default, but optionally disallow them · Issue #3 · tylerchr/jstn · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Proposal: allow undeclared properties by default, but optionally disallow them #3
Open
@davejhilton

Description

@davejhilton

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 o 56A8 f 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0