Multiple form validation fixes

This commit is contained in:
Jorge Vargas 2025-03-10 22:22:52 -06:00
parent 20dd61881c
commit 0e6e08beb2
5 changed files with 55 additions and 55 deletions

View file

@ -2,20 +2,3 @@ import slugify from 'slugify'
export const Status = (status: number, statusText?: string) => new Response(null, { status, statusText })
export const slug = (text: string) => slugify(text, { lower: true, strict: true })
export function formToObject(formData: FormData) {
const object: Record<string, any> = {}
formData.forEach((value, key) => {
// Reflect.has in favor of: object.hasOwnProperty(key)
if (!Reflect.has(object, key)) {
object[key] = value
return
}
if (!Array.isArray(object[key])) {
object[key] = [object[key]]
}
object[key].push(value)
})
return object
}