-
Notifications
You must be signed in to change notification settings - Fork 27.5k
feat(ngModelOptions): add allowInvalid option #8313
Conversation
Thanks for the PR! Please check the items below to help us merge this faster. See the contributing docs for more information.
If you need to make changes to your pull request, you can update the commit with Thanks again for your help! |
The main idea here is that $parsers no longer change the value to undefined in case the value is invalid. Instead, we let This is still a work in progress since I haven't added any docs yet, but I wanted to put it here to get some feedback before I continue. |
Hey @shahata, thanks for working on this. I think we should go one step further and completely decouple $parsers and $validators. With $validators, $parsers should now always return a representation of the model. The problem with date and number is obviously that we have to have some sort of validation to be able to parse them, but that also means the $validators can cleanly expect a Date object respectively a number. |
Hey! Is there any news about this PR? |
Waiting for #8267 |
I've rebased this since #8267 was merged |
I'm fine with this making it into rc.1 cc: @tbosch |
expect(inputElm).toBeInvalid(); | ||
}); | ||
|
||
it('should assign invalid values from $parsers if allowInvalid is true', function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand this test. If the parser decides that the value is not parseable, we still don't get a value in the model, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right. This is a relic from when we still had validators inside $parsers pipeline. This test now does exactly the same as the first one. I removed it.
Could you add the following tests as well:
|
@@ -1633,6 +1633,24 @@ describe('input', function() { | |||
'ng-model-options="{ getterSetter: true }" />'); | |||
}); | |||
|
|||
it('should assign invalid values from $validators if allowInvalid is true', function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please change to: it('should assign invalid values to the scope if allowInvalid is true'...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. Done.
Note: I am in the process of refactoring To be discussed in this PR: |
np, i'll take care of it when rebasing |
Rebased with #8941 |
I have a PR for removing ctrl.$$invalidModelValue. I can put it up tonight. There is one thing that I'm not sure about, so I'd welcome your input |
This option allows to write invalid values to the model instead of having them become undefined. Closes #8290
This option allows to write invalid values to the model instead of having them become undefined. Use this together with calling `ctrl.$setValidity` directly for displaying errors from serverside validation. Closes angular#8290 Closes angular#8313
This option allows to write invalid values to the model instead of having them become undefined. Use this together with calling `ctrl.$setValidity` directly for displaying errors from serverside validation. Closes angular#8290 Closes angular#8313
This option allows to write invalid values to the model instead of having them become undefined. Use this together with calling `ctrl.$setValidity` directly for displaying errors from serverside validation. Closes angular#8290 Closes angular#8313
This option allows to write invalid values to the model instead of having them become undefined. Use this together with calling `ctrl.$setValidity` directly for displaying errors from serverside validation. Closes angular#8290 Closes angular#8313
This option allows to write invalid values to the model instead of having them become undefined.
Closes #8290