Revision 0.34.48 (#6)
* Support Sparse Array Validation * ChangeLog * Version
This commit is contained in:
@@ -183,4 +183,19 @@ describe('compiler/Array', () => {
|
||||
],
|
||||
})
|
||||
})
|
||||
// ----------------------------------------------------------------
|
||||
// Issue: https://github.com/sinclairzx81/typebox/issues/1519
|
||||
// ----------------------------------------------------------------
|
||||
it('Should correctly handle sparse arrays 1', () => {
|
||||
const T = Type.Array(Type.String())
|
||||
const V = []
|
||||
V[10] = 'hello'
|
||||
Fail(T, V)
|
||||
})
|
||||
it('Should correctly handle sparse arrays 2', () => {
|
||||
const T = Type.Array(Type.Union([Type.String(), Type.Undefined()]))
|
||||
const V = []
|
||||
V[10] = 'hello'
|
||||
Ok(T, V)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -152,4 +152,19 @@ describe('value/check/Array', () => {
|
||||
}),
|
||||
)
|
||||
})
|
||||
// ----------------------------------------------------------------
|
||||
// Issue: https://github.com/sinclairzx81/typebox/issues/1519
|
||||
// ----------------------------------------------------------------
|
||||
it('Should correctly handle sparse arrays 1', () => {
|
||||
const T = Type.Array(Type.String())
|
||||
const V = []
|
||||
V[10] = 'hello'
|
||||
Assert.IsFalse(Value.Check(T, V))
|
||||
})
|
||||
it('Should correctly handle sparse arrays 2', () => {
|
||||
const T = Type.Array(Type.Union([Type.String(), Type.Undefined()]))
|
||||
const V = []
|
||||
V[10] = 'hello'
|
||||
Assert.IsTrue(Value.Check(T, V))
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user