Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only emojis mask #1098

Open
rodrigoaguilera opened this issue Dec 4, 2024 · 1 comment
Open

Only emojis mask #1098

rodrigoaguilera opened this issue Dec 4, 2024 · 1 comment

Comments

@rodrigoaguilera
Copy link

rodrigoaguilera commented Dec 4, 2024

What problem you are trying to solve?
I'm trying to create a mask for allowing only emojis

Describe the solution you'd like
To be able to use character class escapes to define the regex for the mask
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Unicode_character_class_escape
For example
/\p{Emoji_Presentation}/u.test('😅')
This returns true
but the following code doesn't mask the field to only allow emojis. It doesn't allow any input.

      IMask(field, {
        mask: /^\p{Emoji_Presentation}+$/u
      });

Describe alternatives you've considered

I also tried

      IMask(field, {
        mask: '0#0000',
        definitions: {
          '#': /\p{Emoji_Presentation}/u
        }
      });
@rodrigoaguilera
Copy link
Author

I just tried

         mask: value => {
           console.log(value);
           return /^\p{Emoji_Presentation}*$/u.test(value)
         }

and value comes as some garbage like instead of the emoji so there probably some issue on the value arrives to be evaluated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant