Skip to content

Instantly share code, notes, and snippets.

@CharlieGreenman
Created September 20, 2019 12:45
Show Gist options
  • Save CharlieGreenman/c5d3a339e474aae0c9163433f2691e02 to your computer and use it in GitHub Desktop.
Save CharlieGreenman/c5d3a339e474aae0c9163433f2691e02 to your computer and use it in GitHub Desktop.
import { Directive } from '@angular/core';
import { AbstractControl, NG_VALIDATORS, ValidationErrors, Validator } from '@angular/forms';
import { LoanAmountValidatorService } from './loan-amount-validator.service';
@Directive({
selector: '[razrooLoanAmount]',
providers: [{ provide: NG_VALIDATORS, useExisting: LoanAmountDirective, multi: true }]
})
export class LoanAmountDirective implements Validator {
constructor(private loanAmountValidatorService: LoanAmountValidatorService) {}
validate(control: AbstractControl): ValidationErrors {
return this.loanAmountValidatorService.loanAmountValidator(control)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment