Updating the /pet route with the petName and gender fields.
The gender of the pet is only saved in the database as an "M" or "F" character. I tried to use an enum in prisma, but it was breaking everything and it was a lot of work to fix everything. So I decided to type it as a string and in the route validator I did the check
// omitted
const gender = input[this.fieldName].toUpperCase()
if (typeof gender !== 'string') {
return new InvalidParamError(this.fieldName)
}
if (!['M', 'F'].includes(gender)) {
return new InvalidParamError(this.fieldName)
}
// omitted
Updating the
/pet
route with thepetName
andgender
fields.The gender of the pet is only saved in the database as an "M" or "F" character. I tried to use an enum in prisma, but it was breaking everything and it was a lot of work to fix everything. So I decided to type it as a string and in the route validator I did the check