Assert.ensure spec
Some possible thoughts on this
Bryan Tong, [21.08.20 22:48] i was thinking of a coercer tied to Assert.ensure()
const arr = Assert.ensure('Array', req.body.foo)
const obj = Assert.ensure('Object', req.body.bar)
const i = Assert.ensure('Number', req.body.baz)
Bryan Tong, [21.08.20 22:50] so req.body.foo = 'foo' becomes ['foo'] or req.body.bar = 'bar' becomes { 0: 'bar' }, and req.body.baz = '10,000' becomes Number(10000)
Bryan Tong, [21.08.20 22:50] or throw exceptions like assert typically does
Tony Butler, [21.08.20 22:51] yeah coercer plus the standard reject path
Tony Butler, [21.08.20 22:52] and passthru if the thing is already valid as the type
Bryan Tong, [21.08.20 22:52] yea