File tree 2 files changed +40
-2
lines changed
2 files changed +40
-2
lines changed Original file line number Diff line number Diff line change @@ -132,8 +132,11 @@ class NgModelMaxNumberValidator implements NgValidator {
132
132
try {
133
133
num parsedValue = double .parse (value);
134
134
_max = parsedValue.isNaN ? _max : parsedValue;
135
+ } catch (e) {
136
+ _max = null ;
137
+ } finally {
135
138
_ngModel.validateLater ();
136
- } catch (e) {};
139
+ }
137
140
}
138
141
139
142
bool isValid (modelValue) {
@@ -180,8 +183,11 @@ class NgModelMinNumberValidator implements NgValidator {
180
183
try {
181
184
num parsedValue = double .parse (value);
182
185
_min = parsedValue.isNaN ? _min : parsedValue;
186
+ } catch (e) {
187
+ _min = null ;
188
+ } finally {
183
189
_ngModel.validateLater ();
184
- } catch (e) {};
190
+ }
185
191
}
186
192
187
193
bool isValid (modelValue) {
Original file line number Diff line number Diff line change @@ -595,6 +595,38 @@ void main() {
595
595
596
596
expect (model.valid).toBe (true );
597
597
});
598
+
599
+ it ('ng-min' , () {
600
+ var input = build ('ng-min' , 'number' );
601
+ scope.apply (() {
602
+ scope.context['attr' ] = '5.0' ;
603
+ scope.context['value' ] = 3 ;
604
+ });
605
+
606
+ expect (model.valid).toBe (false );
607
+
608
+ scope.apply (() {
609
+ scope.context['attr' ] = null ;
610
+ });
611
+
612
+ expect (model.valid).toBe (true );
613
+ });
614
+
615
+ it ('ng-max' , () {
616
+ var input = build ('ng-max' , 'number' );
617
+ scope.apply (() {
618
+ scope.context['attr' ] = '5.0' ;
619
+ scope.context['value' ] = 8 ;
620
+ });
621
+
622
+ expect (model.valid).toBe (false );
623
+
624
+ scope.apply (() {
625
+ scope.context['attr' ] = null ;
626
+ });
627
+
628
+ expect (model.valid).toBe (true );
629
+ });
598
630
});
599
631
});
600
632
}
You can’t perform that action at this time.
0 commit comments