Skip to content
This repository has been archived by the owner on Nov 15, 2017. It is now read-only.

Commit

Permalink
Fix context
Browse files Browse the repository at this point in the history
  • Loading branch information
fastner committed May 12, 2016
1 parent 5eb660b commit 67e522b
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/VuexValidator.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ function computedValidation(id, rulesLength)
}
}

function callValidatorFunction(validatorFunction, state)
{
return function()
{
validatorFunction.call(this, state)
}
}

function install(Vue, { validators: _validators } = { validators: [] })
{
/* eslint no-invalid-this: 0, no-console:0 */
Expand Down Expand Up @@ -89,7 +97,7 @@ function install(Vue, { validators: _validators } = { validators: [] })
// TODO: Cache generated getters like Vuex do
rules.forEach((rule, index) =>
{
getters[`${id}${index}`] = () => rule.validatorFunction(state)
getters[`${id}${index}`] = callValidatorFunction(rule.validatorFunction, state)
})
getters[id] = computedValidation(id, rulesLength)
}
Expand Down

0 comments on commit 67e522b

Please sign in to comment.