File tree Expand file tree Collapse file tree 2 files changed +7
-3
lines changed Expand file tree Collapse file tree 2 files changed +7
-3
lines changed Original file line number Diff line number Diff line change 1
- import { isBlank , isPresent } from 'angular2/src/core/facade/lang' ;
2
- import { CONST_EXPR } from 'angular2/src/core/facade/lang' ;
1
+ import { isBlank , isPresent , CONST_EXPR } from 'angular2/src/core/facade/lang' ;
3
2
import { ListWrapper , StringMapWrapper } from 'angular2/src/core/facade/collection' ;
4
3
import { OpaqueToken } from 'angular2/src/core/di' ;
5
4
@@ -81,7 +80,7 @@ export class Validators {
81
80
82
81
return function ( control : modelModule . AbstractControl ) {
83
82
var res = ListWrapper . reduce ( validators , ( res , validator ) => {
84
- var errors = validator ( control ) ;
83
+ var errors = isPresent ( validator ) ? validator ( control ) : null ;
85
84
return isPresent ( errors ) ? StringMapWrapper . merge ( < any > res , < any > errors ) : res ;
86
85
} , { } ) ;
87
86
return StringMapWrapper . isEmpty ( res ) ? null : res ;
Original file line number Diff line number Diff line change @@ -82,6 +82,11 @@ export function main() {
82
82
var c = Validators . compose ( [ Validators . nullValidator , Validators . nullValidator ] ) ;
83
83
expect ( c ( new Control ( "" ) ) ) . toEqual ( null ) ;
84
84
} ) ;
85
+
86
+ it ( "should ignore nulls" , ( ) => {
87
+ var c = Validators . compose ( [ null , Validators . required ] ) ;
88
+ expect ( c ( new Control ( "" ) ) ) . toEqual ( { "required" : true } ) ;
89
+ } ) ;
85
90
} ) ;
86
91
} ) ;
87
92
}
You can’t perform that action at this time.
0 commit comments