useUsernameValidation(username, options?)
useUsernameValidation(React hook for validating a username against the current Auth0 username policy.This hook checks the provided username against all configured validation rules and returns a structured result describing whether it passes. Optionally, it can send validation errors to the global error manager so that UI components observing theusername,options?):UsernameValidationResult
username field can automatically display or react
to these errors.Parameters
The username string to validate.
options?
When
true, validation errors are stored in the global error manager under the username field. Defaults to false.Returns
UsernameValidationResultA UsernameValidationResult object with:isValid—trueif the username satisfies all configured rules.errors— an array of per-rule validation errors withcode,message, andisValid.
Supported Screens
signupsignup-id
Example
Remarks
- When
includeInErrorsis enabled, the hook automatically updates the errors to the error-store which can be consumed byuseErrorshook. - The hook only recomputes when
usernameoroptions.includeInErrorschange.