@teamnovu/kit-vue-forms 0.1.4 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +13 -13
- package/package.json +1 -1
- package/src/composables/useValidation.ts +4 -4
package/dist/index.js
CHANGED
|
@@ -284,19 +284,21 @@ function he(r, e) {
|
|
|
284
284
|
validators: W([b(e)]),
|
|
285
285
|
isValidated: !1,
|
|
286
286
|
errors: f(e.errors) ?? m.errors
|
|
287
|
-
})
|
|
287
|
+
}), s = (l = m.errors) => {
|
|
288
|
+
t.errors = S(f(e.errors) ?? m.errors, l);
|
|
289
|
+
};
|
|
288
290
|
F(() => f(e.errors), async () => {
|
|
289
291
|
if (t.isValidated) {
|
|
290
|
-
const l = await
|
|
291
|
-
|
|
292
|
+
const l = await n();
|
|
293
|
+
s(l.errors);
|
|
292
294
|
} else
|
|
293
|
-
|
|
295
|
+
s();
|
|
294
296
|
}, { immediate: !0 }), F(
|
|
295
297
|
[() => t.validators],
|
|
296
298
|
async (l) => {
|
|
297
299
|
if (t.isValidated)
|
|
298
300
|
if (l) {
|
|
299
|
-
const c = await
|
|
301
|
+
const c = await n();
|
|
300
302
|
t.errors = c.errors;
|
|
301
303
|
} else
|
|
302
304
|
t.errors = m.errors;
|
|
@@ -305,7 +307,7 @@ function he(r, e) {
|
|
|
305
307
|
), F(() => r.data, () => {
|
|
306
308
|
t.isValidated && h();
|
|
307
309
|
});
|
|
308
|
-
const
|
|
310
|
+
const o = (l) => {
|
|
309
311
|
const c = k(l) ? l : b(l);
|
|
310
312
|
return t.validators.push(c), Q() && X(() => {
|
|
311
313
|
t.validators = t.validators.filter(
|
|
@@ -313,7 +315,7 @@ function he(r, e) {
|
|
|
313
315
|
);
|
|
314
316
|
}), c;
|
|
315
317
|
};
|
|
316
|
-
async function
|
|
318
|
+
async function n() {
|
|
317
319
|
const l = await Promise.all(
|
|
318
320
|
t.validators.filter((u) => f(u) !== void 0).map((u) => f(u).validate(r.data))
|
|
319
321
|
), c = l.every((u) => u.isValid);
|
|
@@ -327,11 +329,9 @@ function he(r, e) {
|
|
|
327
329
|
isValid: c
|
|
328
330
|
};
|
|
329
331
|
}
|
|
330
|
-
const
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
const l = await o();
|
|
334
|
-
return n(l.errors), t.isValidated = !0, {
|
|
332
|
+
const h = async () => {
|
|
333
|
+
const l = await n();
|
|
334
|
+
return s(l.errors), t.isValidated = !0, {
|
|
335
335
|
isValid: !M(l.errors),
|
|
336
336
|
errors: t.errors
|
|
337
337
|
};
|
|
@@ -339,7 +339,7 @@ function he(r, e) {
|
|
|
339
339
|
return {
|
|
340
340
|
...N(t),
|
|
341
341
|
validateForm: h,
|
|
342
|
-
defineValidator:
|
|
342
|
+
defineValidator: o,
|
|
343
343
|
isValid: v
|
|
344
344
|
};
|
|
345
345
|
}
|
package/package.json
CHANGED
|
@@ -122,6 +122,10 @@ export function useValidation<T extends FormDataDefault>(
|
|
|
122
122
|
errors: unref(options.errors) ?? SuccessValidationResult.errors,
|
|
123
123
|
})
|
|
124
124
|
|
|
125
|
+
const updateErrors = (newErrors: ErrorBag = SuccessValidationResult.errors) => {
|
|
126
|
+
validationState.errors = mergeErrors(unref(options.errors) ?? SuccessValidationResult.errors, newErrors)
|
|
127
|
+
}
|
|
128
|
+
|
|
125
129
|
// Watch for changes in the error bag and update validation state
|
|
126
130
|
watch(() => unref(options.errors), async () => {
|
|
127
131
|
if (validationState.isValidated) {
|
|
@@ -198,10 +202,6 @@ export function useValidation<T extends FormDataDefault>(
|
|
|
198
202
|
}
|
|
199
203
|
}
|
|
200
204
|
|
|
201
|
-
const updateErrors = (newErrors: ErrorBag = SuccessValidationResult.errors) => {
|
|
202
|
-
validationState.errors = mergeErrors(unref(options.errors) ?? SuccessValidationResult.errors, newErrors)
|
|
203
|
-
}
|
|
204
|
-
|
|
205
205
|
const validateForm = async (): Promise<ValidationResult> => {
|
|
206
206
|
const validationResults = await getValidationResults()
|
|
207
207
|
|