Back to Browse

EP 14.1 - Angular / Advanced Topics / Custom Form Validators

24.5K views
Dec 26, 2018
16:16

πŸ“š Read the book πŸ‘‰ https://go.asim.dev/angular-book πŸ”₯ Level up your JavaScript πŸ‘‰ https://go.asim.dev/advjs 🌿 If you find my videos useful please consider planting a tree for me πŸ‘‰ https://go.asim.dev/trees πŸŽ₯ Watch the full playlist πŸ‘‰ https://go.asim.dev/angular-playlist The best place to view the code associated with this course is in the online book (https://go.asim.dev/angular-book) via the book if a lecture has code associated with it, it then also has a link to a stackblitz instance so you can run and edit the code sample online. 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.

Download

0 formats

No download links available.

EP 14.1 - Angular / Advanced Topics / Custom Form Validators | NatokHD