Solutionunvalidated

Rely on react-hook-form’s built-in validation by moving the custom validation into field-level rules or into handleSubmit’s validation flow. Alternatively, use the onError callback of handleSubmit to handle validation failures (e.g., set root errors there) instead of checking formState.errors inside onSave immediately after setError.

181dca39-31ea-4d16-a8a9-49d6bdac52e4

Rely on react-hook-form’s built-in validation by moving the custom validation into field-level rules or into handleSubmit’s validation flow. Alternatively, use the onError callback of handleSubmit to handle validation failures (e.g., set root errors there) instead of checking formState.errors inside onSave immediately after setError.