Skip to content

Instantly share code, notes, and snippets.

@brachi-wernick
Last active April 10, 2018 19:36
Show Gist options
  • Save brachi-wernick/08fe39f200e15f507673987dd97b30a2 to your computer and use it in GitHub Desktop.
Save brachi-wernick/08fe39f200e15f507673987dd97b30a2 to your computer and use it in GitHub Desktop.
maxLengthValidatorFn.ts
export function requiredIf(requiredIf:boolean): ValidatorFn {
return (control: AbstractControl): ValidationErrors | null => {
let value = c.value;
if ((value == null || value == undefined || value == "") && requiredIf) {
return {
requiredIf: {condition:requiredIf}
};
}
return null;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment