mirror of
https://github.com/bitwarden/browser
synced 2025-12-13 06:43:35 +00:00
* [deps] Autofill: Update prettier to v3 * prettier formatting updates --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Jonathan Prusik <jprusik@classynemesis.com>
22 lines
628 B
TypeScript
22 lines
628 B
TypeScript
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,
|
|
};
|
|
}
|
|
};
|
|
}
|