Step Validation
The Stepper enables you to set validation logic for each of its steps.
Based on that logic, a success or error icon will be rendered for previous steps, that is, for steps whose index is less than the index of the current step. You can render validation icons either in the step indicator or as a part of the step label, depending on the current Stepper configuration options.
By default, the validation logic is executed only for previous steps.
Setup
To enable the step validation, configure the isValid
option of the steps that has to be validated. It accepts both boolean
and StepPredicateFn
parameters.
Validation Logic
The Stepper enables you to specify custom validation logic for each step by providing a StepPredicateFn
function for the isValid
property of the step. This functionality is useful for scenarios where the validity of the step has to correspond to the state of some external content, for example, a form.
Controlling the Validation
By default, the Stepper validates only previous steps (whose index is less than the index of the current step). You can override this behavior by using the validate
option of the steps. It accepts both boolean
and StepPredicateFn
parameters and allows you to have full control over which steps to validate and when.
If provided, a step will only be validated when its validate
option is true
. This allows the handling of specific scenarios such as validating certain steps only when a specific step is reached, validating all steps when the last step is reached, or even forcing the validation for future steps (that were previously visited by the user).
Triggering the Validation
As an addition to the validate
option of the steps, the Stepper allows you to manually trigger the validation of the steps at any moment. To achieve this, invoke the validateSteps
method of the component.
Steps that have their
validate
property set tofalse
, will not be validated.
Custom Validation Icons
The Stepper allows you to customize the rendered validation icons. To achieve this, specify the successSVGIcon
and errorSVGIcon
properties of the Stepper, and provide the CSS classes that have to be applied to the icons.