Skip to content

Commit af6ecf8

Browse files
authored
fix(core): allow Observable for validation.messages property (#2297)
1 parent 2d3514a commit af6ecf8

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

demo/src/app/examples/advanced/json-schema/object.type.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,4 @@ import { FieldType } from '@ngx-formly/core';
1414
</div>
1515
`,
1616
})
17-
export class ObjectTypeComponent extends FieldType {
18-
defaultOptions = {
19-
defaultValue: {},
20-
};
21-
}
17+
export class ObjectTypeComponent extends FieldType {}

src/core/src/lib/components/formly.field.config.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { FormGroup, AbstractControl, FormGroupDirective, FormArray, AsyncValidatorFn, ValidatorFn } from '@angular/forms';
22
import { Subject, Observable } from 'rxjs';
33
import { FieldType } from '../templates/field.type';
4-
import { TemplateManipulators } from '../services/formly.config';
4+
import { TemplateManipulators, ValidationMessageOption } from '../services/formly.config';
55
import { ComponentFactoryResolver, ComponentRef, Injector } from '@angular/core';
66

77
export interface FormlyFieldConfig {
@@ -48,7 +48,7 @@ export interface FormlyFieldConfig {
4848
*/
4949
validation?: {
5050
messages?: {
51-
[messageProperties: string]: string | ((error: any, field: FormlyFieldConfig) => string);
51+
[messageProperties: string]: ValidationMessageOption['message'];
5252
};
5353
show?: boolean;
5454
[additionalProperties: string]: any;
@@ -61,7 +61,7 @@ export interface FormlyFieldConfig {
6161
*
6262
* {
6363
* validation?: (string | ValidatorFn)[];
64-
* [key: string]: ((control: AbstractControl, field: FormlyFieldConfig) => boolean) | ({ expression: (control: AbstractControl, field: FormlyFieldConfig) => boolean, message: string | ((error, field: FormlyFieldConfig) => string) });
64+
* [key: string]: ((control: AbstractControl, field: FormlyFieldConfig) => boolean) | ({ expression: (control: AbstractControl, field: FormlyFieldConfig) => boolean, message: ValidationMessageOption['message'] });
6565
* }
6666
*/
6767
validators?: any;

0 commit comments

Comments
 (0)