From dcdb1de7688a3c7439ad192d37653364f3493c7f Mon Sep 17 00:00:00 2001 From: Sebastian Fastner Date: Thu, 12 May 2016 14:59:15 +0200 Subject: [PATCH] Add context to validation aggregator --- src/VuexValidator.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/VuexValidator.js b/src/VuexValidator.js index edd8fb5..0347ada 100644 --- a/src/VuexValidator.js +++ b/src/VuexValidator.js @@ -30,14 +30,14 @@ class GlobalValidator { const validator = new GlobalValidator() -function computedValidation(id, rulesLength) +function computedValidation(context, id, rulesLength) { return function() { let allResults = true for (let index = 0; index < rulesLength; index++) { - const curResult = this[`${id}${index}`] + const curResult = context[`${id}${index}`] if (curResult !== true) if (allResults === true) @@ -101,7 +101,7 @@ function install(Vue, { validators: _validators } = { validators: [] }) { getters[`${id}${index}`] = callValidatorFunction(ruleContext, rule.validatorFunction, state) }) - getters[id] = computedValidation(id, rulesLength) + getters[id] = computedValidation(ruleContext, id, rulesLength) } }) })