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

mask.completed works incorrect with optional tokens #159

Closed
maxmaxme opened this issue May 29, 2023 · 3 comments
Closed

mask.completed works incorrect with optional tokens #159

maxmaxme opened this issue May 29, 2023 · 3 comments

Comments

@maxmaxme
Copy link

Describe the bug

mask.completed returns false if the mask contains optional tokens

I inserted the optional token 0 and expect the method returns true

Steps to reproduce

const mask = new Mask({
    mask: "#-#0",
    tokens: {
      "0": { pattern: /[0-9]/, optional: true },
    },
})

mask.completed("12") // = false

Reproduction link

https://stackblitz.com/edit/js-maska-k9z3pf?file=index.js

@mateuswetah
Copy link

Yeah I'm facing the same issue trying to implement this:

 v-maska
 data-maska="(##)########0"
 data-maska-tokens="0:[0-9]:optional"

The completed event only fires with all the values inserted. Are we misunderstanding the optional usage @beholdr?

@fsblemos
Copy link

fsblemos commented Apr 25, 2024

Same happening here but with an array of masks. It only returns completed after filling the larger one.

Reproduction link:

https://stackblitz.com/edit/vue-maska-kwct9s?file=src%2FApp.vue

@beholdr
Copy link
Owner

beholdr commented Jun 2, 2024

I'm afraid it's too complicated logic to determine which token is optional. It's just checking mask length.

@beholdr beholdr closed this as completed Jun 2, 2024
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

4 participants