revalidate icon indicating copy to clipboard operation
revalidate copied to clipboard

Add props as extra argument to validators.

Open ghedsouza opened this issue 7 years ago • 1 comments

This is a proposed WIP change to add props as a third argument to validators. It is a fix for https://github.com/jfairbank/revalidate/issues/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.

ghedsouza avatar May 16 '18 20:05 ghedsouza

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%> (ø) :arrow_up:
src/internal/internalCombineValidators.js 100% <100%> (ø) :arrow_up:
src/internal/createValidatorWithSingleError.js 100% <100%> (ø) :arrow_up:

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.

codecov-io avatar May 16 '18 20:05 codecov-io