So, let's start by adding Ajv to our project's dependencies:
$ yarn add ajv
Then, in src/validators/users/create.js, import the ajv library as well as our two JSON Schemas:
import Ajv from 'ajv';import profileSchema from '../../schema/users/profile.json';import createUserSchema from '../../schema/users/create.json';import ValidationError from '../errors/validation-error';...
Then, gut out the entire validate function, and replace it with the following:
function validate(req) { const ajvValidate = new Ajv() .addFormat('email', /^[\w.+]+@\w+\.\w+$/) ...