File tree Expand file tree Collapse file tree 2 files changed +3
-1
lines changed Expand file tree Collapse file tree 2 files changed +3
-1
lines changed Original file line number Diff line number Diff line change @@ -123,7 +123,7 @@ export class AbstractControl {
123123 find ( path : List < string | number > | string ) : AbstractControl { return _find ( this , path ) ; }
124124
125125 getError ( errorCode : string , path : List < string > = null ) {
126- var c = this . find ( path ) ;
126+ var c = isPresent ( path ) && ! ListWrapper . isEmpty ( path ) ? this . find ( path ) : this ;
127127 if ( isPresent ( c ) && isPresent ( c . _errors ) ) {
128128 return StringMapWrapper . get ( c . _errors , errorCode ) ;
129129 } else {
Original file line number Diff line number Diff line change @@ -335,12 +335,14 @@ export function main() {
335335 it ( "should return the error when it is present" , ( ) => {
336336 var c = new Control ( "" , Validators . required ) ;
337337 var g = new ControlGroup ( { "one" : c } ) ;
338+ expect ( c . getError ( "required" ) ) . toEqual ( true ) ;
338339 expect ( g . getError ( "required" , [ "one" ] ) ) . toEqual ( true ) ;
339340 } ) ;
340341
341342 it ( "should return null otherwise" , ( ) => {
342343 var c = new Control ( "not empty" , Validators . required ) ;
343344 var g = new ControlGroup ( { "one" : c } ) ;
345+ expect ( c . getError ( "invalid" ) ) . toEqual ( null ) ;
344346 expect ( g . getError ( "required" , [ "one" ] ) ) . toEqual ( null ) ;
345347 expect ( g . getError ( "required" , [ "invalid" ] ) ) . toEqual ( null ) ;
346348 } ) ;
You can’t perform that action at this time.
0 commit comments