fastify validation
import Joi from 'joi'
import { Schema } from '../interfaces/fastify.interface'
export const schemaValidator = (type: string, schemaObject: Record<string, any>): Schema => {
const response = Joi.object().keys({ ...schemaObject })
const payloadType: Record<string, any> = {}
payloadType[type] = response
const validation: Schema = {
schema: { ...payloadType },
validatorCompiler: () => (data) => response.validate(data)
}
return validation
}