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

Commit

Permalink
Bind state to propertyValidator closure
Browse files Browse the repository at this point in the history
  • Loading branch information
fastner committed May 12, 2016
1 parent 8338c1c commit 6914b34
Showing 1 changed file with 19 additions and 17 deletions.
36 changes: 19 additions & 17 deletions src/VuexValidator.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,27 +31,29 @@ class GlobalValidator {

const validator = new GlobalValidator()

const propertyValidator = {
isInvalid: (property) =>
{
const vals = propertyToValidator[property]
if (!vals)
return null

return reduce(vals.map((val) => val.isValid()), (all, self) =>
function propertyValidator(state)
{
return {
isInvalid: (property) =>
{
console.log("TEST >>>>>", all, self)
if (all === true && self === true)
return true
const vals = propertyToValidator[property]
if (!vals)
return null

return reduce(vals.map((val) => val.validatorFunction(state)), (all, self) =>
{
if (all === true && self === true)
return true

if (all !== true && self === true)
return all
if (all !== true && self === true)
return all

if (all === true && self !== true)
return self
if (all === true && self !== true)
return self

return all.concat(self)
})
return all.concat(self)
})
}
}
}

Expand Down

0 comments on commit 6914b34

Please sign in to comment.