PluginProbe
Booktics – Appointment Booking Calendar for Service Businesses / 1.0.3
Booktics – Appointment Booking Calendar for Service Businesses v1.0.3
1.0.29 1.0.28 1.0.27 1.0.26 1.0.25 1.0.24 1.0.23 1.0.22 1.0.21 1.0.20 1.0.19 trunk 1.0.0 1.0.1 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.16 1.0.17 1.0.18 1.0.2 1.0.3 All 31 releases
booktics / trunk / core / appointment / services / appointment-validator.php

appointment-validator.php in Booktics – Appointment Booking Calendar for Service Businesses 1.0.3, at trunk/core/appointment/services/appointment-validator.php

65 lines 2.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Booktics\Appointment\Services;
3
4 use Booktics\Utils\Singleton;
5 use WP_Error;
6
7 class Appointment_Validator {
8
9 use Singleton;
10 /**
11 * Validate data for creating an appointment.
12 * @param array $data
13 * @return WP_Error|null
14 */
15 public static function validate_create(array $data): ?WP_Error {
16 if (empty($data['start_time'])) {
17 return new WP_Error('missing_start_time', __('Start time is required', 'booktics'));
18 }
19 if (empty($data['end_time'])) {
20 return new WP_Error('missing_end_time', __('End time is required', 'booktics'));
21 }
22 if (empty($data['date'])) {
23 return new WP_Error('missing_date', __('Date is required', 'booktics'));
24 }
25 if (empty($data['service_id'])) {
26 return new WP_Error('missing_service_id', __('Service ID is required', 'booktics'));
27 }
28 if (empty($data['team_member_id'])) {
29 return new WP_Error('missing_team_member_id', __('Team member ID is required', 'booktics'));
30 }
31 // Add more validation as needed
32 return null;
33 }
34
35 /**
36 * Validate data for updating an appointment.
37 * @param array $data
38 * @return WP_Error|null
39 */
40 public static function validate_update(array $data): ?WP_Error {
41 if (empty($data)) {
42 return new WP_Error('no_data', __('No data provided for update', 'booktics'));
43 }
44 // Optionally, check for required fields on update
45 return null;
46 }
47
48 /**
49 * Validate data for rescheduling an appointment.
50 * @param array $data
51 * @return WP_Error|null
52 */
53 public static function validate_reschedule(array $data): ?WP_Error {
54 if (empty($data['start_time'])) {
55 return new WP_Error('missing_start_time', __('Start time is required for reschedule', 'booktics'));
56 }
57 if (empty($data['end_time'])) {
58 return new WP_Error('missing_end_time', __('End time is required for reschedule', 'booktics'));
59 }
60 if (empty($data['date'])) {
61 return new WP_Error('missing_date', __('Date is required for reschedule', 'booktics'));
62 }
63 return null;
64 }
65 }