Skip to content

Commit

Permalink
Support dynamic rules for array items
Browse files Browse the repository at this point in the history
  • Loading branch information
alyyousuf7 committed Nov 11, 2016
1 parent 4eb5c31 commit b1d1e17
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/revalidator.js
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,12 @@
var nestedErrors;
for (var i = 0, l = a.length; i < l; i++) {
nestedErrors = [];
validateProperty(object, a[i], property, e, options, nestedErrors);
var newE = e;
if (typeof e === 'function') {
newE = e(a[i]);
}

validateProperty(object, a[i], property, newE, options, nestedErrors);
nestedErrors.forEach(function (err) {
err.property =
(property ? property + '.' : '') +
Expand Down

0 comments on commit b1d1e17

Please sign in to comment.