EP 14.1 - Angular / Advanced Topics / Custom Form Validators

preview_player
Показать описание


A validator in Angular is a function which returns null if a control is valid or an error object if it’s invalid.

For model-driven forms, we create custom validation functions and pass them into the FormControl constructor.

For template driven forms we need to create validator directives and provide the validator function to the directive via DI.

Through careful planning, we can share the same validation code between the model driven and template driven forms.

The validator we created in this lecture hardcodes the domain, in the next lecture we will look at how we can make our validators configurable with different domains.
Рекомендации по теме
Комментарии
Автор

Please provide link for plnkr snippets.

ahsenkh
Автор

I enjoy your videos. You are amazing. Everything is clear except this part emailDomain" { parsedDomain: domain } . Why are we returning this object ?

balsamugosa