| 132 | } |
| 133 | |
| 134 | function getValidity(input: ValidatableElement) { |
| 135 | // The native ValidityState object is live, meaning each property is a getter that returns the current state. |
| 136 | // We need to create a snapshot of the validity state at the time this function is called to avoid unpredictable React renders. |
| 137 | let validity = input.validity; |
| 138 | return { |
| 139 | badInput: validity.badInput, |
| 140 | customError: validity.customError, |
| 141 | patternMismatch: validity.patternMismatch, |
| 142 | rangeOverflow: validity.rangeOverflow, |
| 143 | rangeUnderflow: validity.rangeUnderflow, |
| 144 | stepMismatch: validity.stepMismatch, |
| 145 | tooLong: validity.tooLong, |
| 146 | tooShort: validity.tooShort, |
| 147 | typeMismatch: validity.typeMismatch, |
| 148 | valueMissing: validity.valueMissing, |
| 149 | valid: validity.valid |
| 150 | }; |
| 151 | } |
| 152 | |
| 153 | function getNativeValidity(input: ValidatableElement): ValidationResult { |
| 154 | return { |