File tree Expand file tree Collapse file tree 2 files changed +2
-5
lines changed Expand file tree Collapse file tree 2 files changed +2
-5
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1515### Fixed
1616
1717- Form data was reset to its previous state when ` error ` was thrown.
18+ - Form-level errors can be added with ` setError ` , using an empty string as path.
1819
1920## [ 1.0.0-rc.3]
2021
Original file line number Diff line number Diff line change @@ -70,7 +70,7 @@ export const setMessage = message;
7070 */
7171export function setError < T extends ZodValidation < AnyZodObject > > (
7272 form : SuperValidated < T , unknown > ,
73- path : StringPathLeaves < z . infer < UnwrapEffects < T > > > ,
73+ path : '' | StringPathLeaves < z . infer < UnwrapEffects < T > > > ,
7474 error : string | string [ ] ,
7575 options : { overwrite ?: boolean ; status ?: NumericRange < 400 , 599 > } = {
7676 overwrite : false ,
@@ -82,10 +82,6 @@ export function setError<T extends ZodValidation<AnyZodObject>>(
8282 if ( ! form . errors ) form . errors = { } ;
8383
8484 if ( path === null || path === '' ) {
85- console . warn (
86- 'Warning: Form-level errors added with "setError" will conflict with client-side validation. ' +
87- 'Use refine/superRefine on the schema instead, or the "message" helper.'
88- ) ;
8985 if ( ! form . errors . _errors ) form . errors . _errors = [ ] ;
9086 form . errors . _errors = form . errors . _errors . concat ( errArr ) ;
9187 } else {
You can’t perform that action at this time.
0 commit comments