Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 1dd5d2e

Browse files
Niall SmartIgorMinar
Niall Smart
authored andcommittedAug 9, 2013
docs(ngModel): validators should return undefined for invalid values.
Closes #3525
1 parent 6da835f commit 1dd5d2e

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed
 

Diff for: ‎src/ng/directive/input.js

+7-5
Original file line numberDiff line numberDiff line change
@@ -794,8 +794,12 @@ var VALID_CLASS = 'ng-valid',
794794
* @property {string} $viewValue Actual string value in the view.
795795
* @property {*} $modelValue The value in the model, that the control is bound to.
796796
* @property {Array.<Function>} $parsers Array of functions to execute, as a pipeline, whenever
797-
* the control reads value from the DOM. Each function is called, in turn, passing the value
798-
* through to the next. Used to sanitize / convert the value as well as validation.
797+
the control reads value from the DOM. Each function is called, in turn, passing the value
798+
through to the next. Used to sanitize / convert the value as well as validation.
799+
800+
For validation, the parsers should update the validity state using
801+
{@link ng.directive:ngModel.NgModelController#$setValidity $setValidity()},
802+
and return `undefined` for invalid values.
799803
*
800804
* @property {Array.<Function>} $formatters Array of functions to execute, as a pipeline, whenever
801805
* the model value changes. Each function is called, in turn, passing the value through to the
@@ -1005,11 +1009,9 @@ var NgModelController = ['$scope', '$exceptionHandler', '$attrs', '$element', '$
10051009
* For example {@link ng.directive:input input} or
10061010
* {@link ng.directive:select select} directives call it.
10071011
*
1008-
* It internally calls all `parsers` (including validators) and updates the `$modelValue` and the actual model path.
1012+
* It internally calls all `$parsers` (including validators) and updates the `$modelValue` and the actual model path.
10091013
* Lastly it calls all registered change listeners.
10101014
*
1011-
* If validators determine the value is invalid, the `$modelValue` and the model path will be set to `undefined`.
1012-
*
10131015
* @param {string} value Value from the view.
10141016
*/
10151017
this.$setViewValue = function(value) {

0 commit comments

Comments
 (0)