RonaldJerez / vue-input-facade

A lightweight and dependency free input masking library created specific for Vue
https://ronaldjerez.github.io/vue-input-facade/latest/
182 stars 27 forks source link

optional value like v-mask #23

Closed flourigh closed 2 years ago

flourigh commented 4 years ago

Describe the solution you'd like Add a token optional to use on telephone or other on character not required, example (021) 98689-2332 - (0?##) #####-#### (21) 98689-2332 - (##) #####-#### ? | Optional (next character)

Describe alternatives you've considered https://www.npmjs.com/package/v-mask

RonaldJerez commented 4 years ago

Might be a good feature to add at some point. I may not have the time atm to implement it. I will accept a PR if anyone wants to attempt it.

ktiedt commented 3 years ago

Might I suggest a secondary addition to this... greedy symbols (or a way to make them greedy) so that on could do a mask like: $#+.## that works with $0.35, $100.35, and $1.35 but $.35 would fail since its missing the leading numeric.

Its basically the same principal, adding an additional modifier, if its acceptable I can probably work up a PR for these.

RonaldJerez commented 3 years ago

@ktiedt certainly, contributions are welcomed.

killroyboy commented 3 years ago

I'm interested in this functionality as well. Was there any progress made on a PR?

ktiedt commented 3 years ago

@killroyboy unfortunately I got pulled away from my need for this due to changes in our project, so I never got to take a stab at this.

RonaldJerez commented 2 years ago

Thanks to @dima-bzz this has now been released under the beta tag. I also started adding support for wildcard support using his approach as base. That should be pushed soon as well.

Our approach is a little different than v-mask as we kept the optional character placement as a suffix rather than prefix (same as when using regex):

for example.

A?.## -> 1.22 & 1J.22

If you want to try it out you can install the package with npm install vue-input-facade@beta