@treacherous/vue
Advanced tools
Comparing version 0.3.2 to 0.3.3
@@ -7,2 +7,3 @@ "use strict"; | ||
const SummarySubKey = "summary-subscriptions"; | ||
const ReactiveSubscription = "reactive-subscription"; | ||
exports.ValidateWith = (ruleset, options = {}) => { | ||
@@ -66,2 +67,12 @@ return { | ||
context._validationMetadata = metadata; | ||
if (options.withReactiveValidation) { | ||
metadata[ReactiveSubscription] = context.validationGroup.propertyStateChangedEvent.subscribe((args) => { | ||
if (args.isValid) { | ||
context.$delete(context.modelErrors, args.property); | ||
} | ||
else { | ||
context.$set(context.modelErrors, args.property, args.error); | ||
} | ||
}); | ||
} | ||
metadata[ValidationSubKey] = {}; | ||
@@ -71,2 +82,6 @@ metadata[SummarySubKey] = []; | ||
beforeDestroy() { | ||
const metadata = this._validationMetadata; | ||
if (metadata[ReactiveSubscription]) { | ||
metadata[ReactiveSubscription](); | ||
} | ||
this.validationGroup.release(); | ||
@@ -100,3 +115,5 @@ } | ||
validationState = view_1.ValidationState.valid; | ||
context.$delete(context.modelErrors, propertyNameOrRoute); | ||
if (!metadata[ReactiveSubscription]) { | ||
context.$delete(context.modelErrors, propertyNameOrRoute); | ||
} | ||
} | ||
@@ -106,3 +123,5 @@ else { | ||
validationState = view_1.ValidationState.invalid; | ||
context.$set(context.modelErrors, propertyNameOrRoute, error); | ||
if (!metadata[ReactiveSubscription]) { | ||
context.$set(context.modelErrors, propertyNameOrRoute, error); | ||
} | ||
} | ||
@@ -194,3 +213,5 @@ }; | ||
const metadata = context._validationMetadata; | ||
metadata[SummarySubKey].foreach((x) => x()); | ||
if (metadata[SummarySubKey]) { | ||
metadata[SummarySubKey].forEach((x) => x()); | ||
} | ||
} | ||
@@ -197,0 +218,0 @@ }; |
@@ -5,2 +5,3 @@ import { createGroup } from "@treacherous/core"; | ||
const SummarySubKey = "summary-subscriptions"; | ||
const ReactiveSubscription = "reactive-subscription"; | ||
export const ValidateWith = (ruleset, options = {}) => { | ||
@@ -64,2 +65,12 @@ return { | ||
context._validationMetadata = metadata; | ||
if (options.withReactiveValidation) { | ||
metadata[ReactiveSubscription] = context.validationGroup.propertyStateChangedEvent.subscribe((args) => { | ||
if (args.isValid) { | ||
context.$delete(context.modelErrors, args.property); | ||
} | ||
else { | ||
context.$set(context.modelErrors, args.property, args.error); | ||
} | ||
}); | ||
} | ||
metadata[ValidationSubKey] = {}; | ||
@@ -69,2 +80,6 @@ metadata[SummarySubKey] = []; | ||
beforeDestroy() { | ||
const metadata = this._validationMetadata; | ||
if (metadata[ReactiveSubscription]) { | ||
metadata[ReactiveSubscription](); | ||
} | ||
this.validationGroup.release(); | ||
@@ -98,3 +113,5 @@ } | ||
validationState = ValidationState.valid; | ||
context.$delete(context.modelErrors, propertyNameOrRoute); | ||
if (!metadata[ReactiveSubscription]) { | ||
context.$delete(context.modelErrors, propertyNameOrRoute); | ||
} | ||
} | ||
@@ -104,3 +121,5 @@ else { | ||
validationState = ValidationState.invalid; | ||
context.$set(context.modelErrors, propertyNameOrRoute, error); | ||
if (!metadata[ReactiveSubscription]) { | ||
context.$set(context.modelErrors, propertyNameOrRoute, error); | ||
} | ||
} | ||
@@ -192,3 +211,5 @@ }; | ||
const metadata = context._validationMetadata; | ||
metadata[SummarySubKey].foreach((x) => x()); | ||
if (metadata[SummarySubKey]) { | ||
metadata[SummarySubKey].forEach((x) => x()); | ||
} | ||
} | ||
@@ -195,0 +216,0 @@ }; |
{ | ||
"name": "@treacherous/vue", | ||
"version": "0.3.2", | ||
"version": "0.3.3", | ||
"description": "A vue plugin to use the treacherous validation system", | ||
@@ -16,3 +16,3 @@ "author": "LP", | ||
"@treacherous/core": "^0.17.6", | ||
"@treacherous/view": "^0.4.2" | ||
"@treacherous/view": "^0.4.3" | ||
}, | ||
@@ -19,0 +19,0 @@ "devDependencies": { |
@@ -21,2 +21,3 @@ import { | ||
const SummarySubKey = "summary-subscriptions"; | ||
const ReactiveSubscription = "reactive-subscription"; | ||
@@ -80,2 +81,12 @@ export const ValidateWith = (ruleset: Ruleset, options: RulesetOptions = {}) => { | ||
if(options.withReactiveValidation) | ||
{ | ||
metadata[ReactiveSubscription] = context.validationGroup.propertyStateChangedEvent.subscribe((args: any) => { | ||
if(args.isValid) | ||
{ context.$delete(context.modelErrors, args.property); } | ||
else | ||
{ context.$set(context.modelErrors, args.property, args.error); } | ||
}); | ||
} | ||
metadata[ValidationSubKey] = {}; | ||
@@ -85,2 +96,7 @@ metadata[SummarySubKey] = []; | ||
beforeDestroy() { | ||
const metadata = this._validationMetadata; | ||
if(metadata[ReactiveSubscription]) | ||
{ metadata[ReactiveSubscription](); } | ||
this.validationGroup.release(); | ||
@@ -116,3 +132,5 @@ } | ||
validationState = ValidationState.valid; | ||
context.$delete(context.modelErrors, propertyNameOrRoute); | ||
if(!metadata[ReactiveSubscription]) | ||
{ context.$delete(context.modelErrors, propertyNameOrRoute); } | ||
} | ||
@@ -123,3 +141,5 @@ else | ||
validationState = ValidationState.invalid; | ||
context.$set(context.modelErrors, propertyNameOrRoute, error); | ||
if(!metadata[ReactiveSubscription]) | ||
{ context.$set(context.modelErrors, propertyNameOrRoute, error); } | ||
} | ||
@@ -217,3 +237,5 @@ }; | ||
const metadata = context._validationMetadata; | ||
metadata[SummarySubKey].foreach((x: Function) => x()); | ||
if(metadata[SummarySubKey]) | ||
{ metadata[SummarySubKey].forEach((x: Function) => x()); } | ||
} | ||
@@ -220,0 +242,0 @@ } |
Sorry, the diff of this file is too big to display
213720
1082
Updated@treacherous/view@^0.4.3