Skip to content

Commit 3563aa0

Browse files
committed
Remove isDirty check from validation
1 parent d55caf9 commit 3563aa0

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

src/index.ts

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ const useAJVForm = <T extends Record<string, any>>(
136136
return { isValid: false, data: null };
137137
}
138138

139-
if (!isFormValid(state, initialStateRef.current)) {
139+
if (!isFormValid(state)) {
140140
return { isValid: false, data: null };
141141
}
142142

@@ -155,21 +155,16 @@ const useAJVForm = <T extends Record<string, any>>(
155155
);
156156
};
157157

158-
const isFormValid = (
159-
currentState: IState<T>,
160-
initialState: IState<T>,
161-
): boolean => {
158+
const isFormValid = (currentState: IState<T>): boolean => {
162159
const hasErrors = Object.keys(currentState).some(
163160
(key) => currentState[key].error !== '',
164161
);
165162

166-
const formIsDirty = isFormDirty(currentState, initialState);
167-
168-
return !hasErrors && formIsDirty;
163+
return !hasErrors;
169164
};
170165

171166
const isValid = useMemo(() => {
172-
return isFormValid(state, initialStateRef.current);
167+
return isFormValid(state);
173168
}, [state]);
174169

175170
const isDirty = useMemo(

0 commit comments

Comments
 (0)