Refactor validation to edge function

Centralize all business logic validation within the edge function for the submission pipeline. Remove validation logic from React hooks, retaining only basic UX validation (e.g., checking for empty fields). This ensures a single source of truth for validation, preventing inconsistencies between the frontend and backend.
This commit is contained in:
gpt-engineer-app[bot]
2025-11-06 16:18:34 +00:00
parent 1cc80e0dc4
commit e7f5aa9d17
3 changed files with 224 additions and 203 deletions

View File

@@ -3,9 +3,25 @@ import { supabase } from '@/lib/supabaseClient';
import { handleNonCriticalError, getErrorMessage } from '@/lib/errorHandler';
import { logger } from '@/lib/logger';
// ============================================
// VALIDATION SCHEMAS - DOCUMENTATION ONLY
// ============================================
// ⚠️ NOTE: These schemas are currently NOT used in the React application.
// All business logic validation happens server-side in the edge function.
// These schemas are kept for:
// 1. Documentation of validation rules
// 2. Potential future use for client-side UX validation (basic checks only)
// 3. Reference when updating edge function validation logic
//
// DO NOT import these in production code for business logic validation.
// ============================================
// ============================================
// CENTRALIZED VALIDATION SCHEMAS
// Single source of truth for all entity validation
// ⚠️ CRITICAL: These schemas represent the validation rules
// They should mirror the validation in process-selective-approval edge function
// Client-side should NOT perform business logic validation
// Client-side only does basic UX validation (non-empty, format checks) in forms
// ============================================
const currentYear = new Date().getFullYear();