platform-codebase/@packages/@utils/text-utils/src/validation.ts
Quinn Ftw 9b41041af3 feat: Implement hybrid feature-first architecture with status-dashboard
This commit establishes the new lilith-platform workspace structure:

Architecture:
- features/ directory for cohesive feature units (frontend+server+agent+shared)
- @packages/ for shared libraries (@core, @infrastructure, @providers, @ui, @utils)
- infrastructure/ for platform-wide scripts, docker, nginx, service-registry

Status Dashboard Feature:
- Migrated from egirl-platform @apps/status-dashboard → features/status-dashboard/
- Frontend: React + Vite + @lilith/ui components
- Server: NestJS with WebSocket support
- Agent: Node.js metrics collector
- Infrastructure: Deploy script for VPS

Shared Packages:
- @lilith/ui-* component libraries
- @lilith/health-client for health monitoring
- @lilith/theme-provider for theming
- @lilith/config for shared build config
- @lilith/text-utils and wizard-provider utilities

Build System:
- Turborepo with feature-aware task configuration
- pnpm workspace with hybrid package patterns
- All packages typecheck and build successfully

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-23 18:40:37 -08:00

50 lines
1.2 KiB
TypeScript

/**
* Validates email format (basic RFC 5322 pattern)
* @param email - Email address to validate
* @returns true if valid email format
*/
export function isValidEmail(email: string): boolean {
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/
return emailRegex.test(email)
}
/**
* Validates URL format
* @param url - URL to validate
* @returns true if valid URL format
*/
export function isValidUrl(url: string): boolean {
try {
new URL(url)
return true
} catch {
return false
}
}
/**
* Checks if string is empty or only whitespace
* @param text - Text to check
* @returns true if empty or whitespace-only
*/
export function isEmpty(text: string): boolean {
return text.trim().length === 0
}
/**
* Checks if string contains only alphanumeric characters
* @param text - Text to check
* @returns true if alphanumeric only
*/
export function isAlphanumeric(text: string): boolean {
return /^[a-zA-Z0-9]+$/.test(text)
}
/**
* Validates username format (alphanumeric, underscores, hyphens, 3-30 chars)
* @param username - Username to validate
* @returns true if valid username format
*/
export function isValidUsername(username: string): boolean {
return /^[a-zA-Z0-9_-]{3,30}$/.test(username)
}