-
Notifications
You must be signed in to change notification settings - Fork 11
Open
Description
Description
Some type checker in KsNumber used in combination with KsArray :
Edit : it also occurs with KsBoolean and KsString.
- When calling test1 with
a = 3thena = null, it behaves as expected (null is rejected but 3 is accepted) - When calling test1 with
a = nullthena = 3, it behaves as expected (null is rejected but 3 is accepted) - When calling test2 with
[{ "a": 3 }]then[{ "a": null }], it behaves as expected (null is rejected but 3 is accepted) - When calling test2 with
[{ "a": null }]then[{ "a": 3 }], it treats the second as still beingnull(0.a: { "msg": "Cannot be null", "code": 3 })
Note that it may trigger a whole refresh of the app if used with tsc-watch, thus resolving the issue but not in a good way.
Packages
[email protected]
[email protected]
Minimal reproduction
import { Types, Route } from 'koa-smart';
@Route.Route({
routeBase: '',
})
export default class RouteIndex extends Route {
@Route.Post({
bodyType: Types.object().keys({
a: Types.number().required(),
}),
})
async test1(ctx) {
console.log(this.body(ctx));
}
@Route.Post({
bodyType: Types.array().type(Types.object().keys({
a: Types.number().required(),
})),
})
async test2(ctx) {
console.log(this.body(ctx));
}
}Metadata
Metadata
Assignees
Labels
No labels