Explore the powerful form utilities and custom validators included in this template.
markAllAsTouched(form) - Mark all controls as
touched
getAllErrors(form) - Get all validation errors
getErrorMessage() - Get user-friendly error
messages
formatFieldName() - Format field names nicely
validateForm() - Validate and get error messages
matchesField() - Match another field (e.g.,
password confirmation)
phoneNumber() - Validate phone numbersstrongPassword() - Enforce strong password rules
url() - Validate URLscreditCard() - Validate credit card numbersminAge(), maxAge() - Age validation
dateRange() - Date range validation// Mark all form controls as touched
FormUtils.markAllAsTouched(this.form);
// Get all validation errors
const errors = FormUtils.getAllErrors(this.form);
// Get formatted error message
const msg = FormUtils.getErrorMessage('email', 'required', true);
// In your form definition
this.form = this.fb.group({
password: ['', [Validators.required, CustomValidators.strongPassword()]],
confirmPassword: ['', [
Validators.required,
CustomValidators.matchesField('password')
]],
phone: ['', CustomValidators.phoneNumber()],
website: ['', CustomValidators.url()]
});