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

QInput validation rules give incorrect result for certain numbers #17358

Closed
scottbrodersen opened this issue Jul 9, 2024 · 2 comments
Closed
Labels
area/components bug/1-repro-available A reproduction is available and needs to be confirmed. flavour/vite-plugin Bugs related to Vite usage with Quasar kind/bug 🐞 Qv2 🔝 Quasar v2 issues

Comments

@scottbrodersen
Copy link

What happened?

I have a QInput field of type number using v-model.number. The component has a rule that tests the input value against the regular expression ^[0-9][.][0-9]$ however when the decimal is a 0 the rule fails, e.g. 3.0 fails. Any other decimal number passes, e.g. 3.3.

What did you expect to happen?

Any value that matches the regular expression passes the rule, including 0-decimal values.

Reproduction URL

https://codepen.io/scottbro/pen/GRbRbbB

How to reproduce?

  1. Go to the provided reproduction link.
  2. Enter 3.1 in the input --> rule correctly evaluates the value as valid
  3. Enter 3.0 in the input --> rule incorrectly evaluates the value as invalid

Flavour

Vite Plugin (@quasar/vite-plugin)

Areas

Components (quasar)

Platforms/Browsers

Chrome

Quasar info output

No response

Relevant log output

No response

Additional context

No response

@github-actions github-actions bot added area/components bug/1-repro-available A reproduction is available and needs to be confirmed. flavour/vite-plugin Bugs related to Vite usage with Quasar labels Jul 9, 2024
@RamonDonadeu
Copy link

RamonDonadeu commented Jul 12, 2024

First of all, your codepen is not working, for me at least.
Second. If instead of v-model.number, you use v-model="thenumber" and type="number" it works perfectly with 1.0
https://codepen.io/RamonDonadeu/pen/qBzdZLw?editors=101

@yusufkandemir
Copy link
Member

@RamonDonadeu is right. When you use the number modifier, Vue parses the string to a number. So, the regex would be executed against a number, not a string, and will fail to behave the way you want. So, you can either don't use the number modifier, or update your rules to validate numbers instead of strings.

@yusufkandemir yusufkandemir closed this as not planned Won't fix, can't repro, duplicate, stale Aug 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/components bug/1-repro-available A reproduction is available and needs to be confirmed. flavour/vite-plugin Bugs related to Vite usage with Quasar kind/bug 🐞 Qv2 🔝 Quasar v2 issues
Projects
None yet
Development

No branches or pull requests

3 participants