UNPKG

@sandlada/mdc

Version:

@sandlada/mdc is an open source component library that follows the Material Design 3 design specifications.

7 lines (6 loc) 778 B
/** * @license * Copyright 2023 Google LLC * SPDX-License-Identifier: Apache-2.0 */ class t{constructor(t){this.currentValidity={validity:{},validationMessage:""},this.getCurrentState=t}getValidity(){const t=this.getCurrentState();if(!(!this.prevState||!this.equals(this.prevState,t)))return this.currentValidity;const{validity:i,validationMessage:e}=this.computeValidity(t);return this.prevState=this.copy(t),this.currentValidity={validationMessage:e,validity:{badInput:i.badInput,customError:i.customError,patternMismatch:i.patternMismatch,rangeOverflow:i.rangeOverflow,rangeUnderflow:i.rangeUnderflow,stepMismatch:i.stepMismatch,tooLong:i.tooLong,tooShort:i.tooShort,typeMismatch:i.typeMismatch,valueMissing:i.valueMissing}},this.currentValidity}}export{t as Validator};