@@ -3,7 +3,6 @@ import type { ValidationIssue } from '@decs/typeschema';
3
3
import { pathExists , setPaths , traversePath , traversePaths } from './traversal.js' ;
4
4
import { SuperFormError , type ValidationErrors } from './index.js' ;
5
5
import { mergePath } from './stringPath.js' ;
6
- import type { FormOptions } from './client/index.js' ;
7
6
8
7
export function mapErrors ( errors : ValidationIssue [ ] , shape : SchemaShape ) {
9
8
//console.log('===', errors.length, 'errors', shape);
@@ -91,88 +90,6 @@ export function updateErrors<T extends Record<string, unknown>>(
91
90
return Previous ;
92
91
}
93
92
94
- /*
95
-
96
- console.log('Checking new error', error.path, error.value);
97
-
98
- const isObjectError = error.path[error.path.length - 1] == '_errors';
99
- let previousError = pathExists(Previous, error.path);
100
-
101
- if (!previousError) {
102
- // An object error should be displayed on blur if no error exists
103
- if (event != 'blur') return;
104
-
105
- if (isObjectError) {
106
- setPaths(Previous, [error.path], error.value);
107
- return;
108
- }
109
-
110
- setPaths(Previous, [error.path], undefined);
111
- previousError = pathExists(Previous, error.path)!;
112
- }
113
-
114
- switch (method) {
115
- case undefined:
116
- case 'auto':
117
- if (previousError.key in previousError.parent) {
118
- console.log('Error key existed, setting', previousError.path);
119
- previousError.set(error.value);
120
- break;
121
- } else if (
122
- isObjectError ||
123
- (event == 'blur' &&
124
- error.value &&
125
- LastChanges.map((c) => c.join()).includes(error.path.join()))
126
- ) {
127
- previousError.set(error.value);
128
- }
129
-
130
- break;
131
-
132
- /*
133
- case 'onblur':
134
- if (event == 'blur') previousError.set(data.value);
135
- break;
136
-
137
- case 'oninput':
138
- if (event == 'input') previousError.set(data.value);
139
- break;
140
-
141
- case 'submit-only':
142
- if (event == 'submit') previousError.set(data.value);
143
- break;
144
- */
145
- //path?.set(data.value);
146
-
147
- /*
148
- export function clearErrors<T extends Record<string, unknown>>(
149
- Errors: Writable<ValidationErrors<T>>,
150
- options: {
151
- undefinePath: (string | number | symbol)[] | null;
152
- clearFormLevelErrors: boolean;
153
- }
154
- ) {
155
- Errors.update(($errors) => {
156
- traversePaths($errors, (pathData) => {
157
- if (
158
- pathData.path.length == 1 &&
159
- pathData.path[0] == '_errors' &&
160
- !options.clearFormLevelErrors
161
- ) {
162
- return;
163
- }
164
- if (Array.isArray(pathData.value)) {
165
- return pathData.set(undefined);
166
- }
167
- });
168
-
169
- if (options.undefinePath) setPaths($errors, [options.undefinePath], undefined);
170
-
171
- return $errors;
172
- });
173
- }
174
- */
175
-
176
93
export function flattenErrors ( errors : ValidationErrors < Record < string , unknown > > ) {
177
94
return _flattenErrors ( errors , [ ] ) ;
178
95
}
0 commit comments