Password Validator
<afp-password-validator>
Provides a password input field with live validation feedback. Displays a configurable list of password rules and visually indicates which rules are fulfilled while the user types.
Examples #
Special Characters #
Validates that the password contains a minimum number of chosen special characters.
Toggle #
Use the passwordToggle (passwordtoggle) attribute to add a show/hide password toggle button.
Clearable #
Use the clearable attribute to allow clearing the password input.
Disabled #
Use the disabled attribute to prevent user interaction with the password input.
Invalid #
Use the invalid attribute to display an error state.
Customization #
You can customize the icons and title using slots.
Keycloak #
Use AFP_KC_SPECIAL_CHARS as the chars value to validate against the special characters accepted by Keycloak.
These are: !#$%&'()*+,"-./:;<=>?@^_`{|}~§
Properties
Learn more about properties.
| Name | Description | Reflects |
|---|---|---|
config
|
Configuration object defining the password input and its validation rules.
Can be provided via JavaScript or as a JSON string through the `config` attribute.
Type
AfpPasswordValidatorConfig | undefined
|
|
disabled
|
Disables the password input and prevents user interaction.
Passed through to the internal afp-input.
Type
boolean
Default
false |
|
readonly
|
Sets the password input to readonly.
Passed through to the internal afp-input.
Type
boolean
Default
false |
|
invalid
|
Marks the input as invalid and displays an error message.
Passed through to the internal afp-input.
Type
string | undefined
|
|
value
|
Current value of the password input.
Type
string
Default
'' |
|
passwordToggle
passwordtoggle
|
Enables the password visibility toggle.
Passed through to the internal afp-input.
Type
boolean
Default
false |
|
clearable
|
Adds a clear button when the input has a value.
Passed through to the internal afp-input.
Type
boolean
Default
false |
|
Events
Learn more about events.
| Name | Return | Description |
|---|---|---|
afp-clear
|
void
|
Emitted when the input is cleared.
|
afp-focus
|
void
|
Emitted when the input gains focus.
|
afp-blur
|
void
|
Emitted when the input loses focus.
|
afp-value-changed
|
string
|
Emitted when the input's value changes.
|
Slots
Learn more about slots.
| Name | Description |
|---|---|
default
|
The default slot.
|
fulfilled-icon
|
Icon shown when a rule is fulfilled
|
unfulfilled-icon
|
Icon shown when a rule is not fulfilled
|
password-validator-title
|
Title for the list of password rules.
|
Internationalization
Learn more about internationalization.
| Key | Description |
|---|---|
password-validator.rules.aria-label
|
The aria label for the rules list.
|
password-validator.rule.fulfilled
|
Indicats that the requirement is fulfilled.
|
password-validator.rule.unfulfilled
|
Indicates that the requirement is not fulfilled.
|
CSS Parts
Learn more about CSS Parts.
| Name | Description | Selector |
|---|---|---|
password-validator
|
The component's base wrapper.
|
::part(password-validator)
|
password-validator-input
|
The part for the input.
|
::part(password-validator-input)
|
password-validator-title
|
The part for the title for the list of rules.
|
::part(password-validator-title)
|
password-validator-list
|
The part for the list of rules.
|
::part(password-validator-list)
|
password-validator-list-item
|
The part for each rule.
|
::part(password-validator-list-item)
|
Dependencies
The component automatically brings in the listed items, including any nested dependencies that may exist.
Importing
Using the bundle is the recommended method to include components. If you’d rather handle imports manually, you can use the code examples below.
import '@afp-design-system/core/dist/components/password-validator/password-validator.js';