Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | n/a |
0 / 0 |
n/a |
0 / 0 |
CRAP | n/a |
0 / 0 |
|||
| Validation | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | n/a |
0 / 0 |
|||
| 1 | <?php |
| 2 | |
| 3 | namespace Config; |
| 4 | |
| 5 | use CodeIgniter\Config\BaseConfig; |
| 6 | use CodeIgniter\Validation\StrictRules\CreditCardRules; |
| 7 | use CodeIgniter\Validation\StrictRules\FileRules; |
| 8 | use CodeIgniter\Validation\StrictRules\FormatRules; |
| 9 | use CodeIgniter\Validation\StrictRules\Rules; |
| 10 | |
| 11 | class Validation extends BaseConfig |
| 12 | { |
| 13 | // -------------------------------------------------------------------- |
| 14 | // Setup |
| 15 | // -------------------------------------------------------------------- |
| 16 | |
| 17 | /** |
| 18 | * Stores the classes that contain the |
| 19 | * rules that are available. |
| 20 | * |
| 21 | * @var list<string> |
| 22 | */ |
| 23 | public array $ruleSets = [ |
| 24 | Rules::class, |
| 25 | FormatRules::class, |
| 26 | FileRules::class, |
| 27 | CreditCardRules::class, |
| 28 | ]; |
| 29 | |
| 30 | /** |
| 31 | * Specifies the views that are used to display the |
| 32 | * errors. |
| 33 | * |
| 34 | * @var array<string, string> |
| 35 | */ |
| 36 | public array $templates = [ |
| 37 | 'list' => 'CodeIgniter\Validation\Views\list', |
| 38 | 'single' => 'CodeIgniter\Validation\Views\single', |
| 39 | ]; |
| 40 | |
| 41 | // -------------------------------------------------------------------- |
| 42 | // Rules |
| 43 | // -------------------------------------------------------------------- |
| 44 | |
| 45 | /** |
| 46 | * @var array<string, array<string, string>> |
| 47 | */ |
| 48 | public array $child = [ |
| 49 | 'first_name' => 'required|min_length[2]|max_length[100]', |
| 50 | 'last_name' => 'required|min_length[2]|max_length[100]', |
| 51 | 'birth_date' => 'permit_empty|valid_date[Y-m-d]', |
| 52 | 'gender' => 'permit_empty|in_list[male,female]', |
| 53 | 'academy_level_id' => 'permit_empty|is_not_unique[academy_levels.id]', |
| 54 | 'academy_group_id' => 'permit_empty|is_not_unique[academy_groups.id]', |
| 55 | 'primary_coach_id' => 'permit_empty|is_not_unique[coaches.id]', |
| 56 | 'first_class_at' => 'permit_empty|valid_date[Y-m-d]', |
| 57 | 'status' => 'required|in_list[active,pause,left]', |
| 58 | 'has_siblings' => 'required|in_list[0,1]', |
| 59 | 'notes' => 'permit_empty|max_length[4000]', |
| 60 | 'guardian_name' => 'required|min_length[3]|max_length[150]', |
| 61 | 'guardian_phone' => 'permit_empty|max_length[30]', |
| 62 | 'guardian_email' => 'permit_empty|valid_email|max_length[120]', |
| 63 | ]; |
| 64 | |
| 65 | /** |
| 66 | * @var array<string, array<string, string>> |
| 67 | */ |
| 68 | public array $coach = [ |
| 69 | 'full_name' => 'required|min_length[3]|max_length[150]', |
| 70 | 'display_role' => 'required|max_length[100]', |
| 71 | 'phone' => 'permit_empty|max_length[30]', |
| 72 | 'email' => 'required|valid_email|max_length[120]', |
| 73 | 'avatar_path' => 'permit_empty|max_length[255]', |
| 74 | 'is_active' => 'required|in_list[0,1]', |
| 75 | 'notes' => 'permit_empty|max_length[4000]', |
| 76 | 'username' => 'required|min_length[3]|max_length[30]', |
| 77 | ]; |
| 78 | |
| 79 | /** |
| 80 | * @var array<string, array<string, string>> |
| 81 | */ |
| 82 | public array $academyGroup = [ |
| 83 | 'name' => 'required|min_length[2]|max_length[100]', |
| 84 | 'code' => 'required|min_length[2]|max_length[50]', |
| 85 | 'academy_level_id' => 'permit_empty|is_not_unique[academy_levels.id]', |
| 86 | 'primary_coach_id' => 'permit_empty|is_not_unique[coaches.id]', |
| 87 | 'schedule_summary' => 'permit_empty|max_length[255]', |
| 88 | 'status' => 'required|in_list[active,inactive]', |
| 89 | 'capacity' => 'required|integer|greater_than[0]|less_than_equal_to[40]', |
| 90 | ]; |
| 91 | |
| 92 | /** |
| 93 | * @var array<string, array<string, string>> |
| 94 | */ |
| 95 | public array $academyLevel = [ |
| 96 | 'name' => 'required|min_length[2]|max_length[100]', |
| 97 | 'slug' => 'required|min_length[2]|max_length[100]|alpha_dash', |
| 98 | 'sort_order' => 'required|integer|greater_than_equal_to[1]', |
| 99 | 'color_hex' => 'permit_empty|regex_match[/^#[0-9A-Fa-f]{6}$/]', |
| 100 | 'internal_description' => 'permit_empty|max_length[4000]', |
| 101 | 'parent_description' => 'permit_empty|max_length[4000]', |
| 102 | 'benchmark_minimum' => 'permit_empty|decimal', |
| 103 | 'benchmark_target' => 'permit_empty|decimal', |
| 104 | 'promotion_rules' => 'permit_empty|max_length[4000]', |
| 105 | ]; |
| 106 | |
| 107 | /** |
| 108 | * @var array<string, array<string, string>> |
| 109 | */ |
| 110 | public array $attendanceSession = [ |
| 111 | 'academy_group_id' => 'required|is_not_unique[academy_groups.id]', |
| 112 | 'coach_id' => 'permit_empty|is_not_unique[coaches.id]', |
| 113 | 'session_date' => 'required|valid_date[Y-m-d]', |
| 114 | 'start_time' => 'permit_empty|regex_match[/^(?:[01]\d|2[0-3]):[0-5]\d$/]', |
| 115 | 'end_time' => 'permit_empty|regex_match[/^(?:[01]\d|2[0-3]):[0-5]\d$/]', |
| 116 | 'status' => 'required|in_list[scheduled,completed,cancelled,recovery]', |
| 117 | 'cancelled_reason' => 'permit_empty|max_length[4000]', |
| 118 | 'recovery_for_session_id' => 'permit_empty|is_not_unique[attendance_sessions.id]', |
| 119 | 'notes' => 'permit_empty|max_length[4000]', |
| 120 | ]; |
| 121 | |
| 122 | /** |
| 123 | * @var array<string, array<string, string>> |
| 124 | */ |
| 125 | public array $evaluation = [ |
| 126 | 'evaluation_date' => 'required|valid_date[Y-m-d]', |
| 127 | 'evaluator_coach_id' => 'permit_empty|is_not_unique[coaches.id]', |
| 128 | 'notes' => 'permit_empty|max_length[4000]', |
| 129 | ]; |
| 130 | } |