foxhound87 / mobx-react-form

Reactive MobX Form State Management
https://foxhound87.github.io/mobx-react-form
MIT License
1.09k stars 129 forks source link

Input with type="number" and field rules "required|numeric" is not validating for a specific type of numbers #596

Closed lexprom closed 2 years ago

lexprom commented 2 years ago

I've faced a problem where a field is not valid if the value of it is something like this: +32.45 - decimal with a positive sign I thought the problem was in the validatorjs but it's validating these cases.

Test cases:

  1. "+32" -> true
  2. "32.45" -> true
  3. "-32.45" -> true
  4. "+32.45" -> false

I've created a sandbox with a form and a sandbox with only validatorjs.

foxhound87 commented 2 years ago

it seems something related to the type number on the input. By removing type from bind it gets validated.

lexprom commented 2 years ago

@foxhound87 you mean by removing this part field.bind({ type <--, placeholder }) ? If so, that's exactly the reason the input gets text type and it's not reproducing

lexprom commented 2 years ago

The problem is still there though 👀
Or is it expected behavior?

foxhound87 commented 2 years ago

I see that plain input with type number and value "+32.45" as string is not working

    <input type="number" value="+32.45" />
lexprom commented 2 years ago

It's not even working with the value "+32" for some reason