Skip to content

Instantly share code, notes, and snippets.

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