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