Validation
Async Rules
Check a username against the server while the user types, and show errors that only the server can find after a submit.
What this shows
validateUsernameis anasyncfunction. While it runs, the field'sisValidatingistrueand the field shows "Checking…". See Async validation.debounceValidation={400}waits until typing pauses for 400 ms before validating, so the server isn't asked about every keystroke. If an older check finishes after a newer one, its result is ignored.- On submit,
handleSubmitwaits for pending async validators before callingonSubmit. The button readsformState.isValidatingandformState.isSubmittingto show what's happening. - The server rejects
@example.comaddresses.onSubmitshows that error on the email field withsetError, and returnsfalseso the edits are kept. See Errors from the server.
The TextField component comes from the shared example components.