How do you implement custom validation directives in AngularJS?
Instruction: Describe the process of creating and applying custom validation logic through directives in AngularJS.
Context: Candidates will outline their ability to extend AngularJS's validation framework to suit custom business rules.
Updated
Official answer available
Read the opening below, then unlock the full answer and practical guidance.
Create a directive that requires the ngModel controller and registers a synchronous function in $validators or a promise-returning function in $asyncValidators. Validation should have a named error key and a defined empty-value policy.
This complete module checks a specific email domain while leaving required and general email-format validation to the corresponding built-in constraints:...