Skip to content

Investigate a stricter JSONSchema interface #72

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
cyrilletuzi opened this issue Jan 20, 2019 · 1 comment
Closed

Investigate a stricter JSONSchema interface #72

cyrilletuzi opened this issue Jan 20, 2019 · 1 comment
Assignees

Comments

@cyrilletuzi
Copy link
Owner

This lib uses the JSON schema standard (which allow to describe the structure of a JSON) to validate data retrieved from local storage.

As the goal is to validate data, this lib always supported only a subset of the JSON schema standard. But while not supporting all the features of the standard, this lib has tried until now to:

  • stay compatible with a full JSON schema (so people can use it for other purposes if needed) ;
  • be as simple as possible, for example by making type: 'object' optional when the schema already has properties.

Unfortunately, due to differences and/or limitations of TypeScript, this has lead to a mess with the JSONSchema interface in this lib:

  • autocompletion is not accurate (for example, TypeScript will propose you maxItems in any schemas, while it should be only proposed for arrays) ;
  • as the implementation has been too complex, it has lead recently to a compilation issue because of TypeScript 3.2 regression (see Issue with v7 & TypeScript 3.2 for array or object validation #64).

For v8, it is planned to resolve these problems once and for all. Investigation is needed, but here what is being considered:

  • assume a limited subset of the JSON schema standard = drop support for full JSON schemas (it is very likely that the current interface is already not compatible with all the JSON schema standard, as the standard is becoming more and more complex ; also, I don't think it's a feature widely used)

  • if we want TypeScript to be OK, a discrimitated union type must have a common required property, meaning type will become required even for objects and arrays (which is the common usage by the way).

@cyrilletuzi cyrilletuzi added this to the v8.0 milestone Jan 20, 2019
@cyrilletuzi cyrilletuzi self-assigned this Jan 20, 2019
@cyrilletuzi
Copy link
Owner Author

Fixed in #74, coming in v8.

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

1 participant