Files
HIPCTF2/frontend/src/app/features/setup/setup-create-admin.validators.ts
T

21 lines
773 B
TypeScript

export interface PasswordMatchGroupLike {
get(name: 'password' | 'passwordConfirm'): { value: string | null | undefined } | null;
}
export interface PasswordMatchResult {
passwordMismatch?: boolean;
}
/**
* Group-level validator for the "Confirm Password" field.
* Returns `{ passwordMismatch: true }` when the two values differ,
* or `null` when they match (or when either is empty, so that
* `required`/`minlength` validators can take over).
*/
export function passwordMatchValidator(group: PasswordMatchGroupLike): PasswordMatchResult | null {
const password = group.get('password')?.value;
const confirm = group.get('passwordConfirm')?.value;
if (!password || !confirm) return null;
return password === confirm ? null : { passwordMismatch: true };
}