Skip to content

Commit

Permalink
fix(core): detect validation message changes in expressionProperties (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
aitboudad committed Jun 3, 2022
1 parent 90ef367 commit c7692d9
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/core/src/lib/templates/formly.validation-message.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Component, Input, ChangeDetectionStrategy, OnChanges } from '@angular/core';
import { FormlyConfig, ValidationMessageOption } from '../services/formly.config';
import { FormlyFieldConfig } from '../components/formly.field.config';
import { isObject } from '../utils';
import { FORMLY_VALIDATORS, isObject } from '../utils';
import { Observable, isObservable, of } from 'rxjs';
import { merge } from 'rxjs';
import { startWith, switchMap, filter } from 'rxjs/operators';
Expand All @@ -18,6 +18,7 @@ export class FormlyValidationMessage implements OnChanges {
constructor(private formlyConfig: FormlyConfig) {}

ngOnChanges() {
const EXPR_VALIDATORS = FORMLY_VALIDATORS.map(v => `templateOptions.${v}`);
this.errorMessage$ = merge(
this.field.formControl.statusChanges,
(
Expand All @@ -27,7 +28,10 @@ export class FormlyValidationMessage implements OnChanges {
filter(({ field, type, property }) => {
return (field === this.field)
&& (type === 'expressionChanges')
&& (property.indexOf('validation') !== -1)
&& (
(property.indexOf('validation') !== -1)
|| (EXPR_VALIDATORS.indexOf(property) !== -1)
)
;
}),
)
Expand Down

0 comments on commit c7692d9

Please sign in to comment.