react-maskedinput
react-maskedinput copied to clipboard
Pass value to formatCharacters validate
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.
+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.