Skip to content

Commit 6513a20

Browse files
matskoCameron Knight
authored and
Cameron Knight
committed
feat(NgModel): port the URL input type to use the validators pipeline
1 parent 074572c commit 6513a20

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/ng/directive/input.js

+3-5
Original file line numberDiff line numberDiff line change
@@ -1127,12 +1127,10 @@ function numberInputType(scope, element, attr, ctrl, $sniffer, $browser) {
11271127
function urlInputType(scope, element, attr, ctrl, $sniffer, $browser) {
11281128
textInputType(scope, element, attr, ctrl, $sniffer, $browser);
11291129

1130-
var urlValidator = function(value) {
1131-
return validate(ctrl, 'url', ctrl.$isEmpty(value) || URL_REGEXP.test(value), value);
1130+
ctrl.$validators.url = function(modelValue, viewValue) {
1131+
var value = modelValue || viewValue;
1132+
return ctrl.$isEmpty(value) || URL_REGEXP.test(value);
11321133
};
1133-
1134-
ctrl.$formatters.push(urlValidator);
1135-
ctrl.$parsers.push(urlValidator);
11361134
}
11371135

11381136
function emailInputType(scope, element, attr, ctrl, $sniffer, $browser) {

0 commit comments

Comments
 (0)