From 55a477a729b50c625d0930d98d8ff6d9d856f658 Mon Sep 17 00:00:00 2001 From: Sergey Vinogradov Date: Mon, 27 Jun 2022 23:17:23 +0300 Subject: [PATCH] use more straightforward naming --- packages/field-base/src/validate-mixin.js | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/packages/field-base/src/validate-mixin.js b/packages/field-base/src/validate-mixin.js index 841c9f0898e..5092947d455 100644 --- a/packages/field-base/src/validate-mixin.js +++ b/packages/field-base/src/validate-mixin.js @@ -44,7 +44,7 @@ export const ValidateMixin = dedupingMixin( */ validate() { const isValid = this.checkValidity(); - this._commitValidationResult(isValid); + this._setInvalid(!isValid); this.dispatchEvent(new CustomEvent('validated', { detail: { valid: isValid } })); return isValid; } @@ -59,26 +59,23 @@ export const ValidateMixin = dedupingMixin( } /** - * Sets the `invalid` property according to the given validation result - * if the result passes `_shouldCommitValidationResult`. - * - * @param {boolean} isValid + * @param {boolean} invalid * @protected */ - _commitValidationResult(isValid) { - if (this._shouldCommitValidationResult(isValid)) { - this.invalid = !isValid; + _setInvalid(invalid) { + if (this._shouldSetInvalid(invalid)) { + this.invalid = invalid; } } /** - * Override this method to control which validation results should be committed. + * Override this method to define whether the given `invalid` state should be set. * - * @param {boolean} isValid + * @param {boolean} _invalid * @return {boolean} * @protected */ - _shouldCommitValidationResult(_isValid) { + _shouldSetInvalid(_invalid) { return true; }