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

Unexpected ByContractError with "|" and "Object.<>" and "Array.<>" #25

Open
KaKi87 opened this issue Mar 30, 2022 · 0 comments
Open

Unexpected ByContractError with "|" and "Object.<>" and "Array.<>" #25

KaKi87 opened this issue Mar 30, 2022 · 0 comments

Comments

@KaKi87
Copy link

KaKi87 commented Mar 30, 2022

Testing from DevTools.


byContract.validate('foo', `('foo'|'bar')`)

Expected : 'foo'
Actual : ByContractError: expected ('foo'|'bar') but got string

byContract.validate({ 'foo': true, 'bar': 1 }, `Object.<string, boolean|number>`)

Expected : {foo: true, bar: 1}
Actual : ByContractError: expected Object.<string, boolean|number> but failed on each: invalid contract string, invalid contract "number>"

byContract.validate([true, 1], `Array.<boolean|number>`)

Expected : (2) [true, 1]
Actual : ByContractError: expected Array.<boolean|number> but failed on each: invalid contract string, invalid contract "number>"

byContract.validate({ 'foo': { 'bar': true }}, `Object.<string, Object.<string, boolean>>`)

Expected : {foo: {…}}
Actual : ByContractError: object property foo: invalid contract "boolean>"

byContract.validate([{ 'foo': true, 'bar': 1 }], `Array.<Object.<string, boolean|number>>`)

Expected : [{…}]
Actual : ByContractError: expected Array.<Object.<string, boolean|number>> but failed on each: invalid contract string, invalid contract "number>>"

byContract.validate({ foo: [true, 1] }, `Object.<string, Array.<boolean|number>>`)

Expected : {foo: Array(2)}
Actual : ByContractError: expected Object.<string, Array.<boolean|number>> but failed on each: invalid contract string, invalid contract "number>>"


Thanks

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

1 participant