1
1
import { Component , Input , ChangeDetectionStrategy , OnChanges } from '@angular/core' ;
2
2
import { FormlyConfig , ValidationMessageOption } from '../services/formly.config' ;
3
3
import { FormlyFieldConfig } from '../components/formly.field.config' ;
4
- import { isObject } from '../utils' ;
4
+ import { FORMLY_VALIDATORS , isObject } from '../utils' ;
5
5
import { Observable , isObservable , of } from 'rxjs' ;
6
6
import { merge } from 'rxjs' ;
7
7
import { startWith , switchMap , filter } from 'rxjs/operators' ;
@@ -18,6 +18,7 @@ export class FormlyValidationMessage implements OnChanges {
18
18
constructor ( private formlyConfig : FormlyConfig ) { }
19
19
20
20
ngOnChanges ( ) {
21
+ const EXPR_VALIDATORS = FORMLY_VALIDATORS . map ( v => `templateOptions.${ v } ` ) ;
21
22
this . errorMessage$ = merge (
22
23
this . field . formControl . statusChanges ,
23
24
(
@@ -27,7 +28,10 @@ export class FormlyValidationMessage implements OnChanges {
27
28
filter ( ( { field, type, property } ) => {
28
29
return ( field === this . field )
29
30
&& ( type === 'expressionChanges' )
30
- && ( property . indexOf ( 'validation' ) !== - 1 )
31
+ && (
32
+ ( property . indexOf ( 'validation' ) !== - 1 )
33
+ || ( EXPR_VALIDATORS . indexOf ( property ) !== - 1 )
34
+ )
31
35
;
32
36
} ) ,
33
37
)
0 commit comments