Skip to content

Commit

Permalink
- passed all available arguments to addValidator
Browse files Browse the repository at this point in the history
  • Loading branch information
fantua committed Mar 9, 2018
1 parent 7995392 commit a102de5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/add-validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ export default function addValidator ({ validator, defaultMessage, defaultMsg })
return memoize(function (options={}) {
let msg = toObjectMsg(options.msg || options.message) || defaultMsg

return prepare(options.if, options.unless, options.allowBlank, function (value, allValues) {
let result = validator(options, value, allValues)
return prepare(options.if, options.unless, options.allowBlank, function (...args) {
let result = validator(options, ...args)
if ('boolean' !== typeof result) {
return result ? Validators.formatMessage(result) : null
}
Expand Down
4 changes: 2 additions & 2 deletions src/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export function regFormat (func, messageType) {


export function prepare (ifCond, unlessCond, allowBlank, func) {
return function (value, allValues={}) {
return function (value, allValues={}, ...args) {
if (!value || 'object' !== typeof value) {
value = null == value ? '' : '' + value

Expand All @@ -39,7 +39,7 @@ export function prepare (ifCond, unlessCond, allowBlank, func) {
}
if (('function' !== typeof ifCond || ifCond(allValues, value)) &&
('function' !== typeof unlessCond || !unlessCond(allValues, value))) {
return func(value, allValues)
return func(value, allValues, ...args)
}
}
}
Expand Down

0 comments on commit a102de5

Please sign in to comment.