wm-AllKids-tibi2023/api/hooks/forms/post_create.js
robin eee191955e
All checks were successful
deploy to production / deploy (push) Successful in 49s
form
2023-09-24 09:38:03 +00:00

16 lines
458 B
JavaScript

const { validateFields } = require("./validateFields")
;(function () {
if (context?.data?.formular?.honey) {
throw { status: 400, error: "Bot detection" }
}
delete context.data.formular.honey
/**
* @type {Array<[string, FormObj]>}
*/
let values = Object.entries(context?.data?.formular)
let validation = validateFields(values)
if (validation.length) {
throw { status: 400, error: validation }
}
})()