'Submitting errors to frontend with joi

I have a registration form and I am validating this form with joi. There is no problem so far, I can reflect the errors as json, but I don't know how to print it in the frontend, how can I do that?

I used express-validator before, there was a validationresult structure there, so I could catch errors and send them to the front end. How can I do this here? can you help me.

Validate process like this

const createUserValidation = Joi.object({
    name: Joi.string().required().min(5),
    username : Joi.string().required().min(3),
    password : Joi.string().required().min(8).pattern(new RegExp('^[a-zA-Z0-9]{3,30}$')),
    email: Joi.string().required().email(),

});

In short, I want to transfer the errors returned from here to the front end.

Thank you from now.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source