You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Per-field validator functions for field-level async validation. Run independently from the main schema validator, only for the changed field. A field validator only runs when the schema produces **no error** for that field (schema passes first, then the field validator runs).
120
+
Per-field validator functions for field-level async validation. The `value` parameter is typed based on the field path, so no cast is needed. Run independently from the main schema validator, only for the changed field. A field validator only runs when the schema produces **no error** for that field (schema passes first, then the field validator runs).
121
121
122
122
Return `undefined` for valid, or an error message string for invalid.
123
123
@@ -126,7 +126,7 @@ const form = useForm(userSchema, {
126
126
initialValues: { username: '', email: '' },
127
127
fieldValidators: {
128
128
username: async (value) => {
129
-
const available =awaitcheckUsernameAvailable(valueasstring);
129
+
const available =awaitcheckUsernameAvailable(value);
130
130
returnavailable?undefined:'Username is already taken';
Field validators return `undefined` for valid, or an error message string for invalid. They receive the field value and the full form values object: `(value, values) => string | undefined | Promise<string | undefined>`.
1051
+
Field validators return `undefined` for valid, or an error message string for invalid. They receive the typed field value and the full form values object: `(value: FieldTypeAtPath<TValues, K>, values: TValues) => string | undefined | Promise<string | undefined>` — no cast needed.
1052
1052
1053
1053
---
1054
1054
@@ -1664,9 +1664,8 @@ export function RegistrationForm() {
0 commit comments