vue3-form-validation
Advanced tools
Comparing version 3.1.0 to 3.1.1
@@ -5,8 +5,8 @@ import { Rule } from '../composition/useValidation'; | ||
export declare class Form { | ||
private simpleValidators; | ||
private keyedValidators; | ||
private reactiveFormFields; | ||
private simpleMap; | ||
private keyedMap; | ||
private reactiveFormFieldMap; | ||
private trySetKeyed; | ||
private tryGetKeyed; | ||
private tryGetSimple; | ||
private tryGetKeyed; | ||
submitting: import("vue").Ref<boolean>; | ||
@@ -13,0 +13,0 @@ registerField(uid: number, rules: Rule[], modelValue?: unknown): FormField; |
@@ -7,8 +7,8 @@ import { computed, reactive, ref, unref } from 'vue'; | ||
constructor() { | ||
this.simpleValidators = new Map(); | ||
this.keyedValidators = new Map(); | ||
this.reactiveFormFields = reactive(new Map()); | ||
this.trySetKeyed = trySet(this.keyedValidators); | ||
this.tryGetSimple = tryGet(this.simpleValidators); | ||
this.tryGetKeyed = tryGet(this.keyedValidators); | ||
this.simpleMap = new Map(); | ||
this.keyedMap = new Map(); | ||
this.reactiveFormFieldMap = reactive(new Map()); | ||
this.trySetKeyed = trySet(this.keyedMap); | ||
this.tryGetKeyed = tryGet(this.keyedMap); | ||
this.tryGetSimple = tryGet(this.simpleMap); | ||
this.submitting = ref(false); | ||
@@ -18,3 +18,3 @@ } | ||
const formField = new FormField(rules, modelValue); | ||
const simpleEntry = rules.reduce((simpleEntry, rule, ruleNumber) => { | ||
const simple = rules.reduce((simpleEntry, rule, ruleNumber) => { | ||
const validate = Form.validateFactory(formField, rule, ruleNumber); | ||
@@ -26,13 +26,13 @@ if (validate) { | ||
else { | ||
const keyedEntry = { formField, validator: validate }; | ||
const entry = { formField, validator: validate }; | ||
simpleEntry.keys.push(rule.key); | ||
this.trySetKeyed({ | ||
failure: keyed => keyed.add(keyedEntry) | ||
})(rule.key, new Set([keyedEntry])); | ||
failure: keyed => keyed.add(entry) | ||
})(rule.key, new Set([entry])); | ||
simpleEntry.rollback.push(() => { | ||
this.tryGetKeyed({ | ||
success: keyedEntrys => { | ||
keyedEntrys.delete(keyedEntry); | ||
if (!keyedEntrys.size) { | ||
this.keyedValidators.delete(rule.key); | ||
success: keyed => { | ||
keyed.delete(entry); | ||
if (!keyed.size) { | ||
this.keyedMap.delete(rule.key); | ||
} | ||
@@ -51,4 +51,4 @@ } | ||
}); | ||
this.simpleValidators.set(uid, simpleEntry); | ||
this.reactiveFormFields.set(uid, formField); | ||
this.simpleMap.set(uid, simple); | ||
this.reactiveFormFieldMap.set(uid, formField); | ||
return formField; | ||
@@ -59,3 +59,3 @@ } | ||
const errors = []; | ||
for (const formField of this.reactiveFormFields.values()) { | ||
for (const formField of this.reactiveFormFieldMap.values()) { | ||
errors.push(...formField.getErrors().value); | ||
@@ -67,3 +67,3 @@ } | ||
resetFields(toDefaultValues = true) { | ||
for (const { formField } of this.simpleValidators.values()) { | ||
for (const { formField } of this.simpleMap.values()) { | ||
formField.reset(toDefaultValues); | ||
@@ -74,7 +74,7 @@ } | ||
const promises = []; | ||
for (const { formField, validators } of this.simpleValidators.values()) { | ||
for (const { formField, validators } of this.simpleMap.values()) { | ||
formField.touched = true; | ||
promises.push(...validators.map(v => v())); | ||
} | ||
for (const keyed of this.keyedValidators.values()) { | ||
for (const keyed of this.keyedMap.values()) { | ||
for (const { validator } of keyed) { | ||
@@ -112,4 +112,4 @@ promises.push(validator()); | ||
})(uid); | ||
this.simpleValidators.delete(uid); | ||
this.reactiveFormFields.delete(uid); | ||
this.simpleMap.delete(uid); | ||
this.reactiveFormFieldMap.delete(uid); | ||
} | ||
@@ -169,6 +169,6 @@ getPromisesFor(keys) { | ||
buffer.remove(node); | ||
formField.rulesValidating.value--; | ||
if (!node.value) { | ||
setError(formField, ruleNumber, error); | ||
} | ||
formField.rulesValidating.value--; | ||
} | ||
@@ -175,0 +175,0 @@ else { |
{ | ||
"name": "vue3-form-validation", | ||
"version": "3.1.0", | ||
"version": "3.1.1", | ||
"description": "Vue composition function for Form Validation", | ||
@@ -5,0 +5,0 @@ "author": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
0
40447