import { AbstractControl } from '@angular/forms';
export class MyValidations {
static age(control: AbstractControl) {
const value = control.value;
if (value < 18) {
return {isYoung: true};
}
return null;
}
static ageWithParam(max: number) {
return (control: AbstractControl) => {
const value = control.value;
if (value < max) {
return {isYoung: true};
}
return null;
};
}
}
Last active
June 14, 2021 21:18
-
-
Save nicobytes/12eba093a5f3392ee8772bc70c6cb512 to your computer and use it in GitHub Desktop.
Custom validations in Angular
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment