@ravshansbox/react-form
Advanced tools
Comparing version 0.2.0 to 0.2.1
@@ -7,3 +7,3 @@ import { jsx as _jsx } from "react/jsx-runtime"; | ||
const [toucheds, setToucheds] = useState({}); | ||
const [errors, setErrors] = useState(validate ? validate(values) : {}); | ||
const [errors, setErrors] = useState(typeof validate === 'function' ? validate(values) : {}); | ||
const meta = { toucheds, errors }; | ||
@@ -20,3 +20,3 @@ const setFieldValue = (name, value) => { | ||
const validateForm = () => { | ||
if (validate) { | ||
if (typeof validate === 'function') { | ||
setErrors(validate(values)); | ||
@@ -39,4 +39,3 @@ } | ||
setToucheds(toucheds); | ||
const errors = validate(values); | ||
setErrors(errors); | ||
validateForm(); | ||
if (Object.keys(errors).length === 0) { | ||
@@ -43,0 +42,0 @@ onSubmit(values); |
{ | ||
"name": "@ravshansbox/react-form", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"type": "module", | ||
@@ -5,0 +5,0 @@ "main": "dist", |
3994
100