Skip to content

Commit

Permalink
use more straightforward naming
Browse files Browse the repository at this point in the history
  • Loading branch information
vursen committed Jun 27, 2022
1 parent 9e25578 commit 55a477a
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions packages/field-base/src/validate-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
}

Expand Down

0 comments on commit 55a477a

Please sign in to comment.