Skip to content

Commit c7692d9

Browse files
authored
fix(core): detect validation message changes in expressionProperties (#3330)
fix #3317
1 parent 90ef367 commit c7692d9

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/core/src/lib/templates/formly.validation-message.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Component, Input, ChangeDetectionStrategy, OnChanges } from '@angular/core';
22
import { FormlyConfig, ValidationMessageOption } from '../services/formly.config';
33
import { FormlyFieldConfig } from '../components/formly.field.config';
4-
import { isObject } from '../utils';
4+
import { FORMLY_VALIDATORS, isObject } from '../utils';
55
import { Observable, isObservable, of } from 'rxjs';
66
import { merge } from 'rxjs';
77
import { startWith, switchMap, filter } from 'rxjs/operators';
@@ -18,6 +18,7 @@ export class FormlyValidationMessage implements OnChanges {
1818
constructor(private formlyConfig: FormlyConfig) {}
1919

2020
ngOnChanges() {
21+
const EXPR_VALIDATORS = FORMLY_VALIDATORS.map(v => `templateOptions.${v}`);
2122
this.errorMessage$ = merge(
2223
this.field.formControl.statusChanges,
2324
(
@@ -27,7 +28,10 @@ export class FormlyValidationMessage implements OnChanges {
2728
filter(({ field, type, property }) => {
2829
return (field === this.field)
2930
&& (type === 'expressionChanges')
30-
&& (property.indexOf('validation') !== -1)
31+
&& (
32+
(property.indexOf('validation') !== -1)
33+
|| (EXPR_VALIDATORS.indexOf(property) !== -1)
34+
)
3135
;
3236
}),
3337
)

0 commit comments

Comments
 (0)