Skip to content
This repository has been archived by the owner on Feb 12, 2022. It is now read-only.

properties with in-line types does not validate #83

Closed
jstoiko opened this issue Oct 5, 2016 · 2 comments
Closed

properties with in-line types does not validate #83

jstoiko opened this issue Oct 5, 2016 · 2 comments

Comments

@jstoiko
Copy link
Contributor

jstoiko commented Oct 5, 2016

var ts = require('raml-typesystem').loadType({ type: [ 'string', 'integer' ] })
var result = ts.validate('string')
// result.isOk() is true
result = ts.validate(1)
// but here, result.isOk() is false
@ddenisenko
Copy link
Contributor

The type { type: [ 'string', 'integer' ] } is not valid itself, you can check this by running ts.validateType().

Here is the spec quote: it is not allowed to inherit from different kind of primitive types, for example [ number, string ]

@jstoiko
Copy link
Contributor Author

jstoiko commented Oct 5, 2016

my bad. I was looking to test union types, not multiple inheritance types.

this works:

var ts = require('raml-typesystem').loadType({ type: [ 'string | integer' ] })
var result = ts.validate('string')
// result.isOk() is true
result = ts.validate(1)
// result.isOk() is true

@jstoiko jstoiko closed this as completed Oct 5, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants