Overview
The system implements comprehensive validation rules to ensure data integrity and enforce business logic. These validations occur both on the client-side (real-time) and server-side (API).DNI Validation
Duplicate DNI Detection
Applies to: Students (Alumnos) and Instructors Rule: DNI must be unique across all students and across all instructors (separate namespaces). Implementation:- Real-time validation using
useValidarDniDuplicadohook - Triggers automatically when 9+ digits are entered
- Shows error message if duplicate is found
- Prevents form submission until resolved
useValidarDniDuplicado.ts):
- Student: “Ya existe un alumno con DNI ”
- Instructor: “Ya existe un instructor con DNI ”
- Minimum 9 digits to trigger validation
- Only numbers, no dots or dashes
- Validation excludes current record when editing
Time Validation
End Time Constraint
Rule: Classes cannot end after 18:30 Formula:startTime + duration <= 18:30
Examples:
✅ Valid:
- 30 min class at 18:00 → ends at 18:30 ✅
- 60 min class at 17:30 → ends at 18:30 ✅
- 30 min class at 17:00 → ends at 17:30 ✅
- 60 min class at 18:00 → ends at 19:00 ❌
- 30 min class at 18:15 → ends at 18:45 ❌
- 60 min class at 18:30 → ends at 19:30 ❌
- Start: 09:00
- End: 18:30 (last class must finish by this time)
- Time slots: 30-minute increments
Phone Number Validation
Automatic Prefix Addition
Rule: Phone numbers are automatically prefixed with+549 for Argentine numbers
Format Requirements:
- Input: Enter without leading 0 or 15
- Area Code: Separate field (e.g., “221”)
- Number: Local number (e.g., “1234567”)
- Output:
+549{codigoArea}{telefono}
| Area Code | Phone | Stored As |
|---|---|---|
| 221 | 1234567 | +5492211234567 |
| 11 | 98765432 | +5491198765432 |
| 351 | 5551234 | +5493515551234 |
- Area code: Required, numeric
- Phone: Required, numeric
- Combined length: Validated by backend
- Missing area code: “El código de área es obligatorio”
- Missing phone: “El teléfono es obligatorio”
- Invalid format: “Formato de teléfono inválido”
Class Validation
Trial Class Rules
Rule 1: Student cannot have trial class if they already have classes (programmed/completed) in that specialty Rule 2: Student cannot repeat trial class for the same specialty Rule 3: Trial classes do not count toward monthly quota Rule 4: Only inactive students or new people can take trial classes Validation Logic:-
New Person (not in system):
- Provide first name and last name
- Creates
PersonaPruebarecord alumnoIdisnullpersonaPruebaIdis set
-
Existing Inactive Student:
- Select from student list
- Must be inactive (
activo: false) - Must not have classes in that specialty
- Must not have had trial class in that specialty
- 🎓 Emoji in calendar
- Orange border on class cell
- “Prueba” badge in details
- Alert when editing trial class
Edit Restrictions
Non-Editable States
Rule: Classes cannot be edited once they move beyond PROGRAMADA state Non-editable States:INICIADA- Class in progressCOMPLETADA- Class finishedCANCELADA- Class cancelledACA- Absence with noticeASA- Absence without notice
PROGRAMADA- Scheduled, pending ✅
- Attendance tracking
- Payment calculations
- Statistical reports
- Student progress tracking
Board/Horse Validation
TipoPension and CuotaPension Rules
Rule 1:SIN_CABALLO must have cuotaPension: null
RESERVA_ESCUELA and CABALLO_PROPIO must have cuotaPension set
RESERVA_ESCUELA must use school horse (ESCUELA)
CABALLO_PROPIO must use private horse (PRIVADO)
Remaining Classes Validation
Quota Monitoring
Implementation:useClasesRestantes hook
Calculation:
estaAgotado:clasesRestantes <= 0cercaDelLimite:clasesRestantes <= 2 && clasesRestantes > 0porcentajeUsado:(clasesTomadas / clasesContratadas) * 100
- System allows creating classes even when quota is exhausted
- Shows warnings but doesn’t block
- Requires user confirmation when over quota
- Trial classes don’t count toward quota
Field-Level Validations
Required Fields
Student (Alumno):- ✅ DNI (unique, 9+ digits)
- ✅ Nombre
- ✅ Apellido
- ✅ Fecha de Nacimiento
- ✅ Código de Área
- ✅ Teléfono
- ✅ Cantidad de Clases (4, 8, 12, or 16)
- ✅ Tipo de Pensión
- ⚠️ Email (optional but recommended)
- ✅ DNI (unique, 9+ digits)
- ✅ Nombre
- ✅ Apellido
- ✅ Fecha de Nacimiento
- ✅ Código de Área
- ✅ Teléfono
- ✅ Color
- ⚠️ Email (optional but recommended)
- ✅ Nombre
- ✅ Tipo (ESCUELA or PRIVADO)
- ✅ Especialidad
- ✅ Día
- ✅ Hora
- ✅ Duración (30 or 60)
- ✅ Instructor ID
- ✅ Caballo ID
- ⚠️ Alumno ID (or persona prueba for trial classes)
- ⚠️ Observaciones (optional)