1
votes

I am using joi for validating request like

lastName: Joi.string().trim().min(3).optional().error(new Error('Please enter valid name')),

email: Joi.string().email().required().lowercase().error(new Error('Please enter valid Email ID')),

it is working fine and i am also able to send error using failAction but if both validation fails it only send the first failed

like if you enter lastName as h , and email as S@@com so it send only first error i.e "Please enter valid name" but I want response containing both error

I also try to use failAction but after failing fist validator it ignore all other validator any suggestion how can i get the required result

1

1 Answers

1
votes

set abortEarly: false in server setting by default it is true

server.connection({
    routes: {
        validate: {
            options: {
                abortEarly: false
            }
        }
    }
});

Check here