Refactored a bunch of shit
All checks were successful
Docker Deploy / build-and-push (push) Successful in 3m57s
All checks were successful
Docker Deploy / build-and-push (push) Successful in 3m57s
This commit is contained in:
@@ -2,6 +2,30 @@ import { db } from "../db";
|
||||
import { clients, tags as tagsTable } from "../db/schema";
|
||||
import { eq, and } from "drizzle-orm";
|
||||
|
||||
export const MAX_LENGTHS = {
|
||||
name: 255,
|
||||
email: 320,
|
||||
password: 128,
|
||||
phone: 50,
|
||||
address: 255, // street, city, state, zip, country
|
||||
currency: 10,
|
||||
invoiceNumber: 50,
|
||||
invoiceNotes: 5000,
|
||||
itemDescription: 2000,
|
||||
description: 2000, // time entry description
|
||||
} as const;
|
||||
|
||||
export function exceedsLength(
|
||||
field: string,
|
||||
value: string | null | undefined,
|
||||
maxLength: number,
|
||||
): string | null {
|
||||
if (value && value.length > maxLength) {
|
||||
return `${field} must be ${maxLength} characters or fewer`;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
export async function validateTimeEntryResources({
|
||||
organizationId,
|
||||
clientId,
|
||||
@@ -60,3 +84,9 @@ export function validateTimeRange(
|
||||
|
||||
return { valid: true, startDate, endDate };
|
||||
}
|
||||
|
||||
const EMAIL_REGEX = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
||||
|
||||
export function isValidEmail(email: string): boolean {
|
||||
return EMAIL_REGEX.test(email) && email.length <= 320;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user