Created the validation util

This commit is contained in:
Mathias Wagner 2022-09-09 01:06:54 +02:00
parent 0e04039c15
commit 1514edad54
Signed by: Mathias
GPG Key ID: B8DC354B0A1F5B44

7
util/validate.ts Normal file
View File

@ -0,0 +1,7 @@
import Joi from "joi";
export const validateSchema = (schema: Joi.ObjectSchema, object: any) => {
const {error} = schema.validate(object, {errors: {wrap: {label: ''}}})
return error ? error.details[0].message : undefined;
}