1
0
Fork 0
mirror of synced 2024-10-04 03:54:37 +13:00

Clean code

This commit is contained in:
Adria Navarro 2024-02-22 13:55:26 +01:00
parent 1096b8c7f0
commit fb1bfbdae8

View file

@ -1,12 +1,12 @@
import Joi, { ObjectSchema } from "joi"
import { BBContext } from "@budibase/types"
import Joi from "joi"
import { Ctx } from "@budibase/types"
function validate(
schema: Joi.ObjectSchema | Joi.ArraySchema,
property: string
) {
// Return a Koa middleware function
return (ctx: BBContext, next: any) => {
return (ctx: Ctx, next: any) => {
if (!schema) {
return next()
}
@ -30,7 +30,6 @@ function validate(
const { error } = schema.validate(params)
if (error) {
ctx.throw(400, `Invalid ${property} - ${error.message}`)
return
}
return next()
}