mirror of
https://github.com/jorgev259/soc_site-astro.git
synced 2025-06-29 07:57:41 +00:00
Multiple form validation fixes
This commit is contained in:
parent
20dd61881c
commit
0e6e08beb2
5 changed files with 55 additions and 55 deletions
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue