MCPcopy Create free account
hub / github.com/adobe/react-spectrum / getValidity

Function getValidity

packages/react-aria/src/form/useFormValidation.ts:140–157  ·  view source on GitHub ↗
(input: ValidatableElement)

Source from the content-addressed store, hash-verified

138}
139
140function 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
159function getNativeValidity(input: ValidatableElement): ValidationResult {
160 return {

Callers 1

getNativeValidityFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected