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

Bug - 2 regex for 2 different formats don't work #207

Open
on-valerio-luc opened this issue Nov 10, 2023 · 0 comments
Open

Bug - 2 regex for 2 different formats don't work #207

on-valerio-luc opened this issue Nov 10, 2023 · 0 comments

Comments

@on-valerio-luc
Copy link

on-valerio-luc commented Nov 10, 2023

Hello guys,
I am trying to use two masks for 2 different formats and it looks like it doesn't work perfectly. I am using a v-mask directive and my code looks like this:

 v-mask="{
      mask: ['R ### ### ###', 'SO ### ## ##'],
      tokens: tokens,
    }"

const tokens = {
      O: { pattern: /[oO]/, transform: (v: string) => v.toLocaleUpperCase() },
      R: { pattern: /[rR]/, transform: (v: string) => v.toLocaleUpperCase() },
      S: { pattern: /[sS]/, transform: (v: string) => v.toLocaleUpperCase() },
      '#': { pattern: /[0-9]/ },
    }

the fields lets me input only SO 123 12 12 but not R 123 123 321 (it prevents the R to be inputted). The only way I have now to achieve that is to do

 v-mask="{
      mask: ['R ### ### ###', 'RR ### ## ##'],
      tokens: tokens,
    }"

const tokens = {
      R: { pattern: /[oOrRsS0-9], transform: (v: string) => v.toLocaleUpperCase() },
      '#': { pattern: /[0-9]/ },
    }

which however would let input also 11 123 124 213 or RO 122 12 12 which are not accepted inputs. Any suggestions on how I might solve?
Thanks
Valerio

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