1
0
mirror of https://github.com/bitwarden/jslib synced 2025-12-06 00:03:29 +00:00

Remove unused SSO Form code (#701)

* Remove unused SAML Artifact Binding properties

* Remove unused validators
This commit is contained in:
Thomas Rittson
2022-03-03 07:52:11 +10:00
committed by GitHub
parent 8f5f694a1e
commit adfc2f234d
5 changed files with 3 additions and 38 deletions

View File

@@ -1,25 +1,8 @@
import { AbstractControl, ValidationErrors, ValidatorFn, Validators } from "@angular/forms";
import { requiredIf } from "./requiredIf.validator";
import { AbstractControl, ValidationErrors, Validators } from "@angular/forms";
/**
* A higher order function that takes a ValidatorFn and returns a new validator.
* The new validator only runs the ValidatorFn if the control is dirty. This prevents error messages from being
* displayed to the user prematurely.
*/
function dirtyValidator(validator: ValidatorFn) {
return (control: AbstractControl): ValidationErrors | null => {
return control.dirty ? validator(control) : null;
};
}
export function dirtyRequiredIf(predicate: (predicateCtrl: AbstractControl) => boolean) {
return dirtyValidator(requiredIf(predicate));
}
/**
* Equivalent to dirtyValidator(Validator.required), however using dirtyValidator returns a new function
* each time which prevents formControl.hasError from properly comparing functions for equality.
* Runs Validators.required on a field only if it's dirty. This prevents error messages from being displayed
* to the user prematurely.
*/
export function dirtyRequired(control: AbstractControl): ValidationErrors | null {
return control.dirty ? Validators.required(control) : null;

View File

@@ -1,10 +0,0 @@
import { AbstractControl, ValidationErrors, Validators } from "@angular/forms";
/**
* Returns a new validator which will apply Validators.required only if the predicate is true.
*/
export function requiredIf(predicate: (predicateCtrl: AbstractControl) => boolean) {
return (control: AbstractControl): ValidationErrors | null => {
return predicate(control) ? Validators.required(control) : null;
};
}