Testing the Request
const path = require('path')
const ApiException = require('../utils/ApiException')
const fields = [
'first_name',
'last_name',
'email',
'password',
'password_confirmation',
'phone_number'
]
/**
* @param Object data
*/
const registerUserRequestDto = (data) => {
const errors = []
fields.forEach((field) => {
if (!(field in data)) {
errors.push(`This DTO's property is required: ${field}.`)
}
})
if (errors.length > 0) {
throw new ApiException({
status: 'error',
code: 422,
message: 'Input fields are of not the correct form.',
data: null,
errors
})
}
return data
}
module.exports = registerUserRequestDtoThe Passing Test
The Failing Test
Last updated