@alinporumb/easyform
v1.5.0
Published
EasyForm is a lightweight React hook for easy form management with nested object support and Zod-based validations.
Downloads
6
Readme
EasyForm
EasyForm is a lightweight React hook for easy form management with nested object support and Zod-based validations.
Installation
npm install @alinporumb/easyform
API
useForm(options)
Options
defaultValue
: Initial form values (object)schema
: Zod schema for form validationonSubmit
: Async function to handle form submission
Returns
fields
: Object containing form fields withname
,value
, andonChange
errors
: Object containing form errorsonSubmit
: Function to handle form submissionvalues
: Current form valuessetErrors
: Function to manually set errors
Features
- Nested object support
- Zod-based validation
- Automatic error handling
- Easy integration with existing forms
License
MIT