Search code examples
angularangular-reactive-forms

Angular reactive form validators with state holding?


I have a case when user is on a wizard form and it is possible to get back to previous form step. I have there a validation of some value which is executed by making a http request to backend validation app.

When user will back to this step I don't want to force making this request again, because it is already validated. Is it possible to make this by validators (holding state of current validation) or it is a better idea to place this kind of validation inside a component / directive.


Solution

  • You can create and store new flag validated in Service or Local Storage or in store (if you use NgRx or Akita). When the user data is validated in one step, just mark the flag as true. When user reloads the page or comes back to the step, show the message based on the flag.