Spaces:
Running
Running
Download frontend/src/shared/lib/validation.ts from Shadowfilebot/Bot: direct link, hf CLI and curl.
- Browser
- Download file 601 Bytes
-
https://huggingface.co/spaces/Shadowfilebot/Bot/resolve/main/frontend/src/shared/lib/validation.ts
- Command line
-
hf download hf://spaces/Shadowfilebot/Bot/frontend/src/shared/lib/validation.ts
-
curl -L -o validation.ts https://huggingface.co/spaces/Shadowfilebot/Bot/resolve/main/frontend/src/shared/lib/validation.ts
601 Bytes
| export interface ValidationResult<T> { | |
| ok: boolean; | |
| data?: T; | |
| error?: string; | |
| } | |
| export function requiredText(value: string, label: string, min = 1, max = 500): string | null { | |
| const trimmed = value.trim(); | |
| if (trimmed.length < min) { | |
| return min === 1 ? `${label} không được để trống.` : `${label} phải có ít nhất ${min} ký tự.`; | |
| } | |
| if (trimmed.length > max) { | |
| return `${label} không được vượt quá ${max} ký tự.`; | |
| } | |
| return null; | |
| } | |
| export function validEmail(value: string): boolean { | |
| return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value.trim()); | |
| } | |