import { AbstractControl, ValidationErrors } from '@angular/forms';
import { isValid } from 'iban';

export function checkIban() {
  return (control: AbstractControl): ValidationErrors | null => {
    const iban = control.value;
    if (!iban) {
      return null;
    }
    return isValid(iban) ? null : { ibanNotValid: true };
  };
}
