From c90a6ef49b02aa0d530d2de1ba8a621dfe94b254 Mon Sep 17 00:00:00 2001 From: Hardik Pithva Date: Wed, 6 Nov 2024 09:54:34 +0100 Subject: [PATCH] fix: add `_$isValidator$` property to improve the check --- packages/ui/components/form-core/src/validate/ValidateMixin.js | 2 +- packages/ui/components/form-core/src/validate/Validator.js | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/ui/components/form-core/src/validate/ValidateMixin.js b/packages/ui/components/form-core/src/validate/ValidateMixin.js index 5acd85ca8c..54203380c9 100644 --- a/packages/ui/components/form-core/src/validate/ValidateMixin.js +++ b/packages/ui/components/form-core/src/validate/ValidateMixin.js @@ -687,7 +687,7 @@ export const ValidateMixinImplementation = superclass => } for (const validatorToSetup of this._allValidators) { - if (validatorToSetup.type === undefined) { + if (/** @type {typeof Validator} */ validatorToSetup._$isValidator$ === undefined) { // throws in constructor are not visible to end user so we do both const errorType = Array.isArray(validatorToSetup) ? 'array' : typeof validatorToSetup; const errorMessage = `Validators array only accepts class instances of Validator. Type "${errorType}" found. This may be caused by having multiple installations of "@lion/ui/form-core.js".`; diff --git a/packages/ui/components/form-core/src/validate/Validator.js b/packages/ui/components/form-core/src/validate/Validator.js index 243058f9b5..eeb03b5ee2 100644 --- a/packages/ui/components/form-core/src/validate/Validator.js +++ b/packages/ui/components/form-core/src/validate/Validator.js @@ -32,6 +32,7 @@ export class Validator extends EventTarget { * @type {ValidationType} */ this.type = config?.type || 'error'; + this._$isValidator$ = true; } /**