Created
September 20, 2019 12:45
-
-
Save CharlieGreenman/c5d3a339e474aae0c9163433f2691e02 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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