Skip to content

Add index as argument to createValidator - #62

Open
monrus wants to merge 5 commits into
jfairbank:masterfrom
monrus:master
Open

Add index as argument to createValidator#62
monrus wants to merge 5 commits into
jfairbank:masterfrom
monrus:master

Conversation

@monrus

@monrus monrus commented Dec 8, 2018

Copy link
Copy Markdown

Hi, this pull request allows use index of a current array element for compare with other fields of object in the array.

Example:

'stepTimeIntervals[].to': composeValidators(
    isRequired,
    createValidator(
      message => (value, allValues, idx) => {
        if (!allValues.stepTimeIntervals[idx] || value < allValues.stepTimeIntervals[idx].from) {
          return message
        }
      },
      field => `${field} must be more than from`
      )
  )('')

TODO:
Checking use cases coverage and add tests

@codecov-io

Copy link
Copy Markdown

Codecov Report

Merging #62 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff          @@
##           master    #62   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files          30     30           
  Lines         225    225           
  Branches       62     62           
=====================================
  Hits          225    225
Impacted Files Coverage Δ
src/internal/internalCombineValidators.js 100% <100%> (ø) ⬆️
src/internal/createValidatorWithSingleError.js 100% <100%> (ø) ⬆️
src/createValidator.js 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fb3917d...70a0c28. Read the comment docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants