Overview
Simple Manager Mobile implements validation rules to ensure data integrity and provide a good user experience. Validation occurs before records are saved to the database.Validation Interface
The validation system uses a simple result interface:Indicates whether the validation passed (
true) or failed (false).Error message in Spanish explaining why validation failed. Only present when
valid is false.Record Validation Function
ThevalidateRecord function validates record title and type fields:
Validation Rules
Title Validation
The title field cannot be empty or contain only whitespace.Error message: “Todos los campos son obligatorios”
Title must be at least 3 characters long (after trimming whitespace).Error message: “El título debe tener al menos 3 caracteres”
Title cannot exceed 50 characters (after trimming whitespace).Error message: “El título no puede superar los 50 caracteres”
Titles cannot be duplicated within the database (enforced at database level).
Type Validation
The type field cannot be empty or contain only whitespace.Error message: “Todos los campos son obligatorios”
Type must be at least 3 characters long (after trimming whitespace).Error message: “El tipo debe tener al menos 3 caracteres”
Usage Example
Error Handling
All validation error messages are in Spanish to match the application’s target audience:| Validation Error | Spanish Message |
|---|---|
| Empty fields | ”Todos los campos son obligatorios” |
| Title too short | ”El título debe tener al menos 3 caracteres” |
| Title too long | ”El título no puede superar los 50 caracteres” |
| Type too short | ”El tipo debe tener al menos 3 caracteres” |
Best Practices
- Always trim input: The validator trims whitespace before checking length
- Check early: Validate before attempting database operations
- Show clear errors: Display the validation message to users
- Client-side only: Current validation runs on the client; consider adding server-side validation for multi-user scenarios