Step Validation

The Stepper enables you to set validation logic for each step. Based on it, a success or error icon will be rendered for previous steps (whose index is less than the index of the current step). Validation icons are rendered either in the step indicator or as 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 should be validated. It accepts both boolean and StepPredicateFn parameters.

Example
View Source
Edit In Stackblitz  
Change Theme:

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 should correspond to the state of some external content, for example a form.

Example
View Source
Edit In Stackblitz  
Change Theme:

Controlling the Validation

By default the Stepper validates only previous steps (whose index is less than the index of the current step). This behavior can be overridden by using the validate option of the steps. It accepts both boolean and StepPredicateFn parameters and allows you to have full control over when and which steps to validate.

If provided, a step will only be validated when its validate option is true. This allows handling specific scenarios, such as - validating certain steps only when a specific step is reached; or validating all steps when the last step is reached; or even forcing the validation for future steps (that were previously visited by the user).

Example
View Source
Edit In Stackblitz  
Change Theme:

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 to false, will not be validated.

Example
View Source
Edit In Stackblitz  
Change Theme:

Custom Validation Icons

The Stepper allows you to customize the rendered validation icons. To achieve this specify the successIcon and errorIcon properties of the Stepper and provide the CSS classes that should be applied to the icons.

Example
View Source
Edit In Stackblitz  
Change Theme: