Skip to content

array().includes() should not allow undefined #486

@hueniverse

Description

@hueniverse

I am not sure what's the right way of allowing undefined values in an array but the default should not be to allow it. It is rarely the desired or expected outcome.

        it('errors on undefined value', function (done) {

            var schema = Joi.object({
                test: Joi.array().includes(Joi.number())
            });
            var input = { test: [undefined] };

            schema.validate(input, function (err, value) {

                expect(err).to.exist();
                done();
            });
        });

Reported in hapijs/hapi#2138

Metadata

Metadata

Assignees

Labels

breaking changesChange that can breaking existing codebugBug or defect

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions