Lines 13-53typescript
13 * on success; templates read the first message via `control.errors`.
16/** Mirrors zod `emailSchema`: trimmed, valid email. */
17export const emailValidator: ValidatorFn = (control: AbstractControl): ValidationErrors | null => {
18 const value = (control.value ?? "").toString().trim();
20 return { email: "Please enter a valid email address" };
22 // Same intent as zod's email check: a single @ with non-empty local/domain
23 // parts and a dotted domain. Kept deliberately permissive, like zod.
24 const emailPattern = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
25 return emailPattern.test(value) ? null : { email: "Please enter a valid email address" };
28/** Mirrors zod `passwordSchema`: minimum 8 characters. */
29export const passwordMinValidator: ValidatorFn = (
30 control: AbstractControl,
31): ValidationErrors | null => {
32 const value = (control.value ?? "").toString();
33 return value.length >= 8 ? null : { password: "Password must be at least 8 characters" };
MediumSecret Pattern
Package contains a possible secret pattern.
dist/force-app/main/default/uiBundles/angularexternalapp/src/app/features/authentication/utils/auth-validators.tsView on unpkg · L33 36/** A required-with-custom-message validator (mirrors zod `min(1, message)`). */
37export function requiredWithMessage(message: string): ValidatorFn {
38 return (control: AbstractControl): ValidationErrors | null => {
39 const value = (control.value ?? "").toString().trim();
40 return value.length >= 1 ? null : { required: message };
45 * Cross-field validator mirroring the `newPasswordSchema` refine: the
46 * `confirmPassword` control must equal the `newPassword` control. Attach to the
47 * FormGroup; sets `{ passwordMismatch: '...' }` on the confirm control (matching
48 * the zod `path: ['confirmPassword']`) so the error renders under that field.
50export function passwordsMatchValidator(
51 passwordKey = "newPassword",
52 confirmKey = "confirmPassword",