Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add index as argument to createValidator #62

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

monrus
Copy link

@monrus monrus commented Dec 8, 2018

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

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