formsy-react icon indicating copy to clipboard operation
formsy-react copied to clipboard

Update Validation type

Open th3fallen opened this issue 2 years ago • 3 comments

Update Validation type for custom added validators that leverage the extra argument

Tests run directly on the source code and all dist changes are computed and committed during Formsy release.

th3fallen avatar Mar 03 '22 23:03 th3fallen

This resolves the Ts issue regarding validators that leverage the extra argument like so.

validations={ {
                'isNumeric': true,
                'isGte': min,
                'isLte': max,
              } }
export function isGte(values, value, min) {
  if (!value && value !== 0) {
    return true;
  }
  return value >= min;
}

th3fallen avatar Mar 03 '22 23:03 th3fallen

@th3fallen sorry for the delay, can you elaborate when do you get a type error? (a small example will be really appreciated).

felixmosh avatar Jul 28 '22 07:07 felixmosh

@felixmosh I think I get this. The type error example here is { 'isLte': max }, where max isn't a boolean or a string or a function, so it does not match the previous type.

rkuykendall avatar Oct 28 '22 21:10 rkuykendall