Skip to content

Throws error when field is missing and abortEarly=false #184

@AndrewKeig

Description

@AndrewKeig

Hey,

The below throws an error, this should return :

'the value of username is not allowed to be undefined'

var Joi = require('joi');

var schema = {
  username: Joi.string().required().email()
};

var error = Joi.validate({}, schema, {abortEarly : false});

console.log(error);

Throws the following error:

joi/lib/string.js:168
        if (value.match(regex)) {
                  ^
TypeError: Cannot call method 'match' of undefined

This will also throw an error

var Joi = require('joi');

var schema = {
  password: Joi.string().required().min(6).max(10)
};

var error = Joi.validate({}, schema, {abortEarly : false});

console.log(error);

Produces the following error:

joi/lib/string.js:75
            value.length <= limit) {
                 ^
TypeError: Cannot read property 'length' of undefined

Metadata

Metadata

Assignees

Labels

bugBug or defect

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions