Skip to content

fix(forms): Min/MaxValidator change parseInt to parseFloat - #17436

Closed
SteveVanOpstal wants to merge 1 commit into
angular:masterfrom
SteveVanOpstal:master
Closed

SteveVanOpstal wants to merge 1 commit into
angular:masterfrom
SteveVanOpstal:master

Conversation

@SteveVanOpstal

Copy link
Copy Markdown

Please check if the PR fulfills these requirements

What kind of change does this PR introduce? (check one with "x")

[ x ] Bugfix
[ ] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Other... Please describe:

What is the current behavior? (You can also link to an open issue here)

MinValidator and MaxValidator use parseInt to convert the attribute string to an integer, this does not allow floating point min or max. This is probably due to a reuse of code from MinLengthValidator and MaxLengthValidator.

What is the new behavior?

The following is now possible:

<input [min]="0.55" [max]="1.25">

parseInt is replaced by parseFloat.

Does this PR introduce a breaking change? (check one with "x")

[ ] Yes
[ x ] No

Other information:

Closes #17080

@IgorMinar IgorMinar added area: forms action: review The PR is still awaiting reviews from at least one requested reviewer labels Jul 11, 2017

@kara kara left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change looks good, but can you add some tests for numbers like 3.5? An integration test showing a number input with an appropriate test would also be good.

@kara kara added action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews type: bug/fix and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Feb 21, 2018
@SteveVanOpstal

Copy link
Copy Markdown
Author

@kara the min and max directives no longer exists due to #17551. I am waiting for them to be reintroduced.

@kara

kara commented Apr 5, 2018

Copy link
Copy Markdown
Contributor

Okay, @SteveVanOpstal, feel free to re-open when we decide what to do about those.

@kara kara closed this Apr 5, 2018
@angular-automatic-lock-bot

Copy link
Copy Markdown

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot Bot locked and limited conversation to collaborators Sep 13, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews area: forms cla: yes type: bug/fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ngModel min validator seems ignored

4 participants