Files
openmonetis/lib/utils/string.ts
Felipe Coutinho a7f63fb77a refactor: migrate from ESLint to Biome and extract SQL queries to data.ts
- Replace ESLint with Biome for linting and formatting
- Configure Biome with tabs, double quotes, and organized imports
- Move all SQL/Drizzle queries from page.tsx files to data.ts files
- Create new data.ts files for: ajustes, dashboard, relatorios/categorias
- Update existing data.ts files: extrato, fatura (add lancamentos queries)
- Remove all drizzle-orm imports from page.tsx files
- Update README.md with new tooling info

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-27 13:15:37 +00:00

44 lines
1.2 KiB
TypeScript

/**
* Utility functions for string normalization and manipulation
*/
/**
* Normalizes optional string - trims and returns null if empty
* @param value - String to normalize
* @returns Trimmed string or null if empty
*/
export function normalizeOptionalString(
value: string | null | undefined,
): string | null {
const trimmed = value?.trim() ?? "";
return trimmed.length > 0 ? trimmed : null;
}
/**
* Normalizes file path by extracting filename
* @param path - File path to normalize
* @returns Filename without path
*/
export function normalizeFilePath(path: string | null | undefined): string {
return path?.split("/").filter(Boolean).pop() ?? "";
}
/**
* Normalizes whitespace in string (replaces multiple spaces with single space)
* @param value - String to normalize
* @returns String with normalized whitespace
*/
export function normalizeWhitespace(value: string): string {
return value.replace(/\s+/g, " ").trim();
}
/**
* Normalizes icon input - trims and returns null if empty
* @param icon - Icon string to normalize
* @returns Trimmed icon string or null
*/
export function normalizeIconInput(icon?: string | null): string | null {
const trimmed = icon?.trim() ?? "";
return trimmed.length > 0 ? trimmed : null;
}