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' ;
32import { ListWrapper , StringMapWrapper } from 'angular2/src/core/facade/collection' ;
43import { OpaqueToken } from 'angular2/src/core/di' ;
54
@@ -81,7 +80,7 @@ export class Validators {
8180
8281 return function ( control : modelModule . AbstractControl ) {
8382 var res = ListWrapper . reduce ( validators , ( res , validator ) => {
84- var errors = validator ( control ) ;
83+ var errors = isPresent ( validator ) ? validator ( control ) : null ;
8584 return isPresent ( errors ) ? StringMapWrapper . merge ( < any > res , < any > errors ) : res ;
8685 } , { } ) ;
8786 return StringMapWrapper . isEmpty ( res ) ? null : res ;
Original file line number Diff line number Diff line change @@ -82,6 +82,11 @@ export function main() {
8282 var c = Validators . compose ( [ Validators . nullValidator , Validators . nullValidator ] ) ;
8383 expect ( c ( new Control ( "" ) ) ) . toEqual ( null ) ;
8484 } ) ;
85+
86+ it ( "should ignore nulls" , ( ) => {
87+ var c = Validators . compose ( [ null , Validators . required ] ) ;
88+ expect ( c ( new Control ( "" ) ) ) . toEqual ( { "required" : true } ) ;
89+ } ) ;
8590 } ) ;
8691 } ) ;
8792}
You can’t perform that action at this time.
0 commit comments