Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(demo): fix pattern to allow <1 decimals if can't be zero (#6903)
If an input in the demo can't be zero and a value <1 was given, the check pattern would fail for it, and it'll show the warning that the input isn't valid even though it is valid. This slightly simplifies the regex creation as canBeZero adds `0+|` to the pattern and the main pattern `([0-9]*[1-9][0-9]*)` is always used. Then, if it can be a decimal, it uses the existing pattern but adds `?(0(?=\.))?'` which makes the main pattern optional and instead adds the optionally a `0` but only if it is followed by a `.`. The main pattern `([0-9]*[1-9][0-9]*)` potentially could be simplified into `[1-9]\d*` but it would make leading zeros invalid. --------- Co-authored-by: Álvaro Velad Galván <ladvan91@hotmail.com>
- Loading branch information