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

docs(ngModel): validators should return undefined for invalid values. #3525

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/ng/directive/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -817,6 +817,10 @@ var VALID_CLASS = 'ng-valid',
* @property {Array.<Function>} $parsers Array of functions to execute, as a pipeline, whenever
the control reads value from the DOM. Each function is called, in turn, passing the value
through to the next. Used to sanitize / convert the value as well as validation.
For validation, the parsers should update the validity state using
{@link ng.directive:ngModel.NgModelController#$setValidity $setValidity()},
and return `undefined` for invalid values.

*
* @property {Array.<Function>} $formatters Array of functions to execute, as a pipeline, whenever
the model value changes. Each function is called, in turn, passing the value through to the
Expand Down Expand Up @@ -1042,11 +1046,9 @@ var NgModelController = ['$scope', '$exceptionHandler', '$attrs', '$element', '$
* For example {@link ng.directive:input input} or
* {@link ng.directive:select select} directives call it.
*
* It internally calls all `parsers` (including validators) and updates the `$modelValue` and the actual model path.
* It internally calls all `$parsers` (including validators) and updates the `$modelValue` and the actual model path.
* Lastly it calls all registered change listeners.
*
* If validators determine the value is invalid, the `$modelValue` and the model path will be set to `undefined`.
*
* @param {string} value Value from the view.
*/
this.$setViewValue = function(value) {
Expand Down