@ravshansbox/react-form
Advanced tools
Comparing version 0.1.1 to 0.2.0
@@ -5,3 +5,3 @@ import { ReactElement } from 'react'; | ||
onSubmit: (values: any) => void; | ||
validate: (values: any) => any; | ||
validate?: (values: any) => any; | ||
render: (params: { | ||
@@ -8,0 +8,0 @@ values: any; |
@@ -7,3 +7,3 @@ import { jsx as _jsx } from "react/jsx-runtime"; | ||
const [toucheds, setToucheds] = useState({}); | ||
const [errors, setErrors] = useState(validate(values)); | ||
const [errors, setErrors] = useState(validate ? validate(values) : {}); | ||
const meta = { toucheds, errors }; | ||
@@ -20,3 +20,5 @@ const setFieldValue = (name, value) => { | ||
const validateForm = () => { | ||
setErrors(validate(values)); | ||
if (validate) { | ||
setErrors(validate(values)); | ||
} | ||
}; | ||
@@ -23,0 +25,0 @@ return (_jsx(FormContext.Provider, Object.assign({ value: { |
{ | ||
"name": "@ravshansbox/react-form", | ||
"version": "0.1.1", | ||
"version": "0.2.0", | ||
"type": "module", | ||
@@ -5,0 +5,0 @@ "main": "dist", |
4002
101