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 props as extra argument to validators. #60

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ghedsouza
Copy link

@ghedsouza ghedsouza commented May 16, 2018

This is a proposed WIP change to add props as a third argument to validators. It is a fix for #17.

This change allows you to depend on the props that redux-form passes along to the validate prop.

e.g.

return createValidator(
    message => (value, allValues, props) => {
      if (!allValues || value !== allValues[otherField] || props.forceFail) {
        return message;
      }
    },

    field => `${field} must match ${otherFieldLabel}`
  );

Still TODO:

  1. Update createValidatorWithMultipleErrors.js.
  2. Update tests.

Looking for feedback from the project maintainer before continuing work on this.

@codecov-io
Copy link

Codecov Report

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

Impacted file tree graph

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