(scope, element, attr, ctrl, $sniffer, $browser)
| 17128 | var numberBadFlags = ['badInput']; |
| 17129 | |
| 17130 | function numberInputType(scope, element, attr, ctrl, $sniffer, $browser) { |
| 17131 | textInputType(scope, element, attr, ctrl, $sniffer, $browser); |
| 17132 | |
| 17133 | ctrl.$parsers.push(function(value) { |
| 17134 | var empty = ctrl.$isEmpty(value); |
| 17135 | if (empty || NUMBER_REGEXP.test(value)) { |
| 17136 | ctrl.$setValidity('number', true); |
| 17137 | return value === '' ? null : (empty ? value : parseFloat(value)); |
| 17138 | } else { |
| 17139 | ctrl.$setValidity('number', false); |
| 17140 | return undefined; |
| 17141 | } |
| 17142 | }); |
| 17143 | |
| 17144 | addNativeHtml5Validators(ctrl, 'number', numberBadFlags, null, ctrl.$$validityState); |
| 17145 | |
| 17146 | ctrl.$formatters.push(function(value) { |
| 17147 | return ctrl.$isEmpty(value) ? '' : '' + value; |
| 17148 | }); |
| 17149 | |
| 17150 | if (attr.min) { |
| 17151 | var minValidator = function(value) { |
| 17152 | var min = parseFloat(attr.min); |
| 17153 | return validate(ctrl, 'min', ctrl.$isEmpty(value) || value >= min, value); |
| 17154 | }; |
| 17155 | |
| 17156 | ctrl.$parsers.push(minValidator); |
| 17157 | ctrl.$formatters.push(minValidator); |
| 17158 | } |
| 17159 | |
| 17160 | if (attr.max) { |
| 17161 | var maxValidator = function(value) { |
| 17162 | var max = parseFloat(attr.max); |
| 17163 | return validate(ctrl, 'max', ctrl.$isEmpty(value) || value <= max, value); |
| 17164 | }; |
| 17165 | |
| 17166 | ctrl.$parsers.push(maxValidator); |
| 17167 | ctrl.$formatters.push(maxValidator); |
| 17168 | } |
| 17169 | |
| 17170 | ctrl.$formatters.push(function(value) { |
| 17171 | return validate(ctrl, 'number', ctrl.$isEmpty(value) || isNumber(value), value); |
| 17172 | }); |
| 17173 | } |
| 17174 | |
| 17175 | function urlInputType(scope, element, attr, ctrl, $sniffer, $browser) { |
| 17176 | textInputType(scope, element, attr, ctrl, $sniffer, $browser); |
nothing calls this directly
no test coverage detected