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

Limitations Array and Object schema limitations #33

Open
cyberixae opened this issue Oct 28, 2020 · 1 comment
Open

Limitations Array and Object schema limitations #33

cyberixae opened this issue Oct 28, 2020 · 1 comment

Comments

@cyberixae
Copy link
Contributor

cyberixae commented Oct 28, 2020

According to the specification the following schema is supposed match { foo: 'foo' } and any item that is not an object to begin with.

{
  "properties": {
    "foo": { "const": "foo" }
  }
}

In a similar manner the following schema is supposed to match the tuple [ 'bar', 123 ] and any item that is not an array at all.

{
  "items": [
    { "const": "bar" },
    { "const": 123 }
  ]
}

Iotsfjs currently fails to validate these requirements because I haven't been able to find a good way to describe them in the TypeScript's static type system. Essentially they could be described with somethings like { foo: 'foo' } | Not<Record<string, any>> and ['bar', 123] | Not<Array<any>> but TypeScript doesn't provide Not out of box. It might be possible to represent them with conditional types but this gets quite complicated very easily.

@pulasthibandara
Copy link

could we use the io-ts literal constructor for these constant types?

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