akinncar/react-native-mask-text

Is it possible to either apply a mask or apply none?

seyadeodin opened this issue · 0 comments

I have a field that accept either an e-mail or a phone number, and I would like to know how to not apply a mask when the field is detected as an e-mail. Any falsy value I return receives a type error, since the field only accepts arrays. Is there at least a way of apply a mask that apply no mask?. This is more or less what I was trying to do:

                   mask={(text) => {
                      const isNumber = !isNaN(parseInt(text?.slice(0, 1), 10));
                      const isParenthesis = text?.slice(0, 1) === '(';
                      if (isNumber || isParenthesis) {
                        return masks.phone;
                      } else {
                        return false;
                      }
                    }}