1
0
mirror of https://github.com/bitwarden/jslib synced 2026-01-02 16:43:39 +00:00

Merge branch 'master' of https://github.com/bitwarden/jslib into feature/additional-item-types-scaffold

This commit is contained in:
Hinton
2022-05-13 14:42:20 +02:00
30 changed files with 12126 additions and 1017 deletions

View File

@@ -0,0 +1,21 @@
import { AbstractControl, AsyncValidatorFn, ValidationErrors } from "@angular/forms";
export function notAllowedValueAsync(
valueGetter: () => Promise<string>,
caseInsensitive = false
): AsyncValidatorFn {
return async (control: AbstractControl): Promise<ValidationErrors | null> => {
let notAllowedValue = await valueGetter();
let controlValue = control.value;
if (caseInsensitive) {
notAllowedValue = notAllowedValue.toLowerCase();
controlValue = controlValue.toLowerCase();
}
if (controlValue === notAllowedValue) {
return {
notAllowedValue: true,
};
}
};
}