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

Pass value to formatCharacters validate

Open MikeDevice opened this issue 7 years ago • 1 comments

How about passing input value to validate method in formatCharacters. I think it will be convenient. Example

<MaskedInput
  formatCharacters={{
    'w': {
      validate(char, value) {
        return value.length === 1 && char === 'w' || value.length === 2 && char === 'W';
      },
    }
  }}
/>

This example does not make sense, but this functional can be useful.

MikeDevice avatar Apr 03 '17 08:04 MikeDevice

+1. This is needed, if we need to validate the expiry-date is between 0 and 12, and return empty otherwise. Without this, I'm not sure how you can achieve this feature, as this function gives single char at a time.

jainprash avatar Oct 25 '17 18:10 jainprash