From 0b97918d1e913e450b1023dcb9c2a8bca258dd60 Mon Sep 17 00:00:00 2001 From: AndreeaMoise Date: Wed, 10 Aug 2022 10:59:12 +0200 Subject: [PATCH] fix(form-core): getMessage return type supports string and Element (#1756) * fix: getMessage return type supports string and Element * Add changeset --- .changeset/mighty-frogs-wave.md | 5 +++++ packages/form-core/types/validate/validate.d.ts | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 .changeset/mighty-frogs-wave.md diff --git a/.changeset/mighty-frogs-wave.md b/.changeset/mighty-frogs-wave.md new file mode 100644 index 000000000..01ccd3a54 --- /dev/null +++ b/.changeset/mighty-frogs-wave.md @@ -0,0 +1,5 @@ +--- +'@lion/form-core': patch +--- + +Extend type of getMessage to allow it being implemented as a sync function. diff --git a/packages/form-core/types/validate/validate.d.ts b/packages/form-core/types/validate/validate.d.ts index 6fcfbeb01..d8892bbd4 100644 --- a/packages/form-core/types/validate/validate.d.ts +++ b/packages/form-core/types/validate/validate.d.ts @@ -27,7 +27,7 @@ export type ValidatorParam = any; * Will be stored on Validator instance and passed to `execute` function */ export type ValidatorConfig = { - getMessage?: (data: Partial) => Promise; + getMessage?: (data: Partial) => Promise | string | Element; type?: ValidationType; node?: FormControlHost; fieldName?: string | Promise;