@startsimpli/auth 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,34 @@
1
+ export const EMAIL_REGEX = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
2
+
3
+ export function validateEmail(email: string): boolean {
4
+ return EMAIL_REGEX.test(email);
5
+ }
6
+
7
+ export interface PasswordValidationResult {
8
+ isValid: boolean;
9
+ error?: string;
10
+ }
11
+
12
+ // Canonical password rules for all StartSimpli apps
13
+ export function validatePassword(password: string): PasswordValidationResult {
14
+ if (password.length < 8) {
15
+ return { isValid: false, error: 'Password must be at least 8 characters' };
16
+ }
17
+ if (!/[A-Z]/.test(password)) {
18
+ return { isValid: false, error: 'Password must contain at least one uppercase letter' };
19
+ }
20
+ if (!/[a-z]/.test(password)) {
21
+ return { isValid: false, error: 'Password must contain at least one lowercase letter' };
22
+ }
23
+ if (!/[0-9]/.test(password)) {
24
+ return { isValid: false, error: 'Password must contain at least one number' };
25
+ }
26
+ return { isValid: true };
27
+ }
28
+
29
+ export function validatePasswordConfirm(password: string, confirm: string): PasswordValidationResult {
30
+ if (password !== confirm) {
31
+ return { isValid: false, error: 'Passwords do not match' };
32
+ }
33
+ return validatePassword(password);
34
+ }