Validation, Custom Validators, FormArray, Dynamic Forms and Submission
Learn Validation, Custom Validators, FormArray, Dynamic Forms and Submission (Phase 7 · Forms (Core), Angular) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.
Built-in and custom validators • Built-ins: Validators.required , requiredTrue , min , max , minLength , maxLength , pattern , email , compose . • A custom validator is a function (control) => ValidationErrors | null : return null when valid, an object { errorKey: details } when invalid. Use a factory function to pass parameters. • A cross-field validator is applied to the group and reads several controls (password match, date range). • An async validator returns an Observable/Promise (is this username taken?) and runs only after sync validators pass; debounce it.