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

Commit

Permalink
Allow multiple returns in module validator
Browse files Browse the repository at this point in the history
  • Loading branch information
fastner committed May 17, 2016
1 parent ae29d28 commit 95a6b97
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/BaseValidator.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,17 @@ export default class BaseValidator {
{
const valid = rule.validatorFunction(state)

if (valid && valid.valid === false)
return {
if (valid && valid.length > 0)
{
let valids = valid.filter((item) => item.valid === false).map((item) => ({
name: rule.name,
fields: valid.fields,
error: valid.error
}
fields: item.fields,
error: item.error
}))

if (valids.length > 0)
return valids
}

return true
}
Expand Down

0 comments on commit 95a6b97

Please sign in to comment.