formdata-schema
TypeScript icon, indicating that this package has built-in type declarations

0.1.13 • Public • Published

formdata-schema

Parse your FormData with a simple schema.

Installation

pnpm i formdata-schema

Usage

import { parse } from 'formdata-schema'

// data: FormData
const parsed = parse(data, {
	first_name: 'nonempty',
	last_name: 'nonempty',
	height: 'number',
	birthdate: 'date',
	avatar: 'fileOptional',
	note: 'text',
})

Type of parsed:

Error | {
    first_name: string // length > 0
    last_name: string // length > 0
    height: number
    birthdate: Date
    avatar: File | null
    note: string
}

Package Sidebar

Install

npm i formdata-schema

Weekly Downloads

1

Version

0.1.13

License

ISC

Unpacked Size

4.71 kB

Total Files

4

Last publish

Collaborators

  • aljaroudi