hjkcai / typesafe-joi

A fork of joi that produces typed validation results in TypeScript
MIT License
73 stars 9 forks source link

Problem with Joi.alternatives #20

Closed thomasmikava closed 5 years ago

thomasmikava commented 5 years ago

Consider the following schema:

const schema = Joi.alternatives([
    Joi.number(),
    Joi.array().items(Joi.number()),
]);

This produces a correct type number | number[]

However, if I add allow(null),

const schema = Joi.alternatives([
    Joi.number(),
    Joi.array().items(Joi.number()),
]).allow(null);

then the produced type is only number[], while it has to be number | number[] | null

hjkcai commented 5 years ago

Fixed in 2.0.6