When creating a custom async validator for a form control, which type should the validator return to indicate a validation error?

  • Boolean
  • Number
  • Observable
  • String
When creating a custom async validator for a form control in frameworks like Angular, the validator should return an Observable to indicate a validation error. This allows you to handle asynchronous validation, such as making HTTP requests to validate the input. Observables provide a convenient way to handle async operations and emit error values when validation fails. Using other types like numbers, strings, or booleans would not be suitable for asynchronous validation scenarios.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *