mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-16 23:19:40 +02:00
style: auto-format codebase with Prettier
Applied formatting to 1487+ files using pnpm format:write - TypeScript/JavaScript files - Svelte components - Astro pages - JSON configs - Markdown docs 13 files still need manual review (Astro JSX comments)
This commit is contained in:
parent
0241f5554c
commit
d36b321d9d
3952 changed files with 661498 additions and 739751 deletions
|
|
@ -6,29 +6,29 @@
|
|||
* Validate email address format
|
||||
*/
|
||||
export function isValidEmail(email: string): boolean {
|
||||
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
||||
return emailRegex.test(email);
|
||||
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
||||
return emailRegex.test(email);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate URL format
|
||||
*/
|
||||
export function isValidUrl(url: string): boolean {
|
||||
try {
|
||||
new URL(url);
|
||||
return true;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
new URL(url);
|
||||
return true;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate phone number (basic international format)
|
||||
*/
|
||||
export function isValidPhone(phone: string): boolean {
|
||||
// Allows: +49123456789, 0123456789, +1 (555) 123-4567
|
||||
const phoneRegex = /^[+]?[(]?[0-9]{1,4}[)]?[-\s./0-9]*$/;
|
||||
return phoneRegex.test(phone) && phone.replace(/\D/g, '').length >= 6;
|
||||
// Allows: +49123456789, 0123456789, +1 (555) 123-4567
|
||||
const phoneRegex = /^[+]?[(]?[0-9]{1,4}[)]?[-\s./0-9]*$/;
|
||||
return phoneRegex.test(phone) && phone.replace(/\D/g, '').length >= 6;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -36,67 +36,68 @@ export function isValidPhone(phone: string): boolean {
|
|||
* Returns an object with validation details
|
||||
*/
|
||||
export function validatePassword(password: string): {
|
||||
isValid: boolean;
|
||||
hasMinLength: boolean;
|
||||
hasUppercase: boolean;
|
||||
hasLowercase: boolean;
|
||||
hasNumber: boolean;
|
||||
hasSpecialChar: boolean;
|
||||
score: number;
|
||||
isValid: boolean;
|
||||
hasMinLength: boolean;
|
||||
hasUppercase: boolean;
|
||||
hasLowercase: boolean;
|
||||
hasNumber: boolean;
|
||||
hasSpecialChar: boolean;
|
||||
score: number;
|
||||
} {
|
||||
const hasMinLength = password.length >= 8;
|
||||
const hasUppercase = /[A-Z]/.test(password);
|
||||
const hasLowercase = /[a-z]/.test(password);
|
||||
const hasNumber = /[0-9]/.test(password);
|
||||
const hasSpecialChar = /[!@#$%^&*(),.?":{}|<>]/.test(password);
|
||||
const hasMinLength = password.length >= 8;
|
||||
const hasUppercase = /[A-Z]/.test(password);
|
||||
const hasLowercase = /[a-z]/.test(password);
|
||||
const hasNumber = /[0-9]/.test(password);
|
||||
const hasSpecialChar = /[!@#$%^&*(),.?":{}|<>]/.test(password);
|
||||
|
||||
const score = [hasMinLength, hasUppercase, hasLowercase, hasNumber, hasSpecialChar]
|
||||
.filter(Boolean).length;
|
||||
const score = [hasMinLength, hasUppercase, hasLowercase, hasNumber, hasSpecialChar].filter(
|
||||
Boolean
|
||||
).length;
|
||||
|
||||
return {
|
||||
isValid: hasMinLength && hasUppercase && hasLowercase && hasNumber,
|
||||
hasMinLength,
|
||||
hasUppercase,
|
||||
hasLowercase,
|
||||
hasNumber,
|
||||
hasSpecialChar,
|
||||
score,
|
||||
};
|
||||
return {
|
||||
isValid: hasMinLength && hasUppercase && hasLowercase && hasNumber,
|
||||
hasMinLength,
|
||||
hasUppercase,
|
||||
hasLowercase,
|
||||
hasNumber,
|
||||
hasSpecialChar,
|
||||
score,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a string is empty or only whitespace
|
||||
*/
|
||||
export function isEmpty(value: string | null | undefined): boolean {
|
||||
return !value || value.trim().length === 0;
|
||||
return !value || value.trim().length === 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a string exceeds max length
|
||||
*/
|
||||
export function isWithinMaxLength(value: string, maxLength: number): boolean {
|
||||
return value.length <= maxLength;
|
||||
return value.length <= maxLength;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a string meets minimum length
|
||||
*/
|
||||
export function meetsMinLength(value: string, minLength: number): boolean {
|
||||
return value.length >= minLength;
|
||||
return value.length >= minLength;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate UUID format
|
||||
*/
|
||||
export function isValidUuid(uuid: string): boolean {
|
||||
const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
||||
return uuidRegex.test(uuid);
|
||||
const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
||||
return uuidRegex.test(uuid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate hex color format
|
||||
*/
|
||||
export function isValidHexColor(color: string): boolean {
|
||||
const hexRegex = /^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/;
|
||||
return hexRegex.test(color);
|
||||
const hexRegex = /^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/;
|
||||
return hexRegex.test(color);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue