Skip to content

Instantly share code, notes, and snippets.

@CharlieGreenman
Created September 20, 2019 12:44
Show Gist options
  • Save CharlieGreenman/4419a0aaef17a43d04ddd7d6c6d019b0 to your computer and use it in GitHub Desktop.
Save CharlieGreenman/4419a0aaef17a43d04ddd7d6c6d019b0 to your computer and use it in GitHub Desktop.
import { Injectable } from '@angular/core';
import { FormGroup, ValidationErrors, ValidatorFn } from '@angular/forms';
@Injectable({
providedIn: 'root'
})
export class LoanAmountValidatorService {
constructor() { }
identityRevealedValidator: ValidatorFn = (formGroup: FormGroup): ValidationErrors | null => {
const income = formGroup.get('income');
const expenses = formGroup.get('expenses');
return income && expenses && income.value - expenses.value > 100000 ? { 'loanAmount': true } : null;
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment