Skip to content

Commit

Permalink
fix: add _$isValidator$ property to improve the check
Browse files Browse the repository at this point in the history
  • Loading branch information
hardikpthv committed Nov 6, 2024
1 parent 51dc412 commit c90a6ef
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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".`;
Expand Down
1 change: 1 addition & 0 deletions packages/ui/components/form-core/src/validate/Validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export class Validator extends EventTarget {
* @type {ValidationType}
*/
this.type = config?.type || 'error';
this._$isValidator$ = true;
}

/**
Expand Down

0 comments on commit c90a6ef

Please sign in to comment.