Unexpected ByContractError with "|" and "Object.<>" and "Array.<>"
KaKi87 opened this issue · comments
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