1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
CommonEventCategoryValidators.php
См. документацию.
1<?php
2
4
6
8{
12 public static function validateName($name, bool $required = true): array
13 {
14 $errors = [];
15
16 if ($required && !$name)
17 {
18 $errors[] = new Error(
19 message: 'name required',
20 customData: ['field_name' => 'name']
21 );
22 }
23
24 if (!$errors && (!is_string($name) || mb_strlen($name) > 255))
25 {
26 $errors[] = new Error(
27 message: 'name invalid',
28 customData: ['field_name' => 'name']
29 );
30 }
31
32 return $errors;
33 }
34
38 public static function validateDescription($description, bool $required = false): array
39 {
40 $errors = [];
41
42 if ($required && !$description)
43 {
44 $errors[] = new Error(
45 message: 'description required',
46 customData: ['field_name' => 'description']
47 );
48 }
49
50 if (!$errors && !is_string($description))
51 {
52 $errors[] = new Error(
53 message: 'description invalid',
54 customData: ['field_name' => 'description']
55 );
56 }
57
58 return $errors;
59 }
60
64 public static function validateClosed($closed): array
65 {
66 $errors = [];
67
68 if (
69 is_string($closed)
70 && !in_array($closed, ['true', 'false'], true)
71 )
72 {
73 $errors = [
74 new Error(
75 message: 'closed invalid',
76 customData: ['field_name' => 'closed']
77 )
78 ];
79 }
80
81 return $errors;
82 }
83
87 public static function validateAttendees(bool $closed, array $attendees): array
88 {
89 $errors = [];
90 if (!$closed && !empty($attendees))
91 {
92 $errors[] = new Error(
93 message: 'attendees should be empty',
94 code: 'attendees_should_be_empty',
95 customData: ['field_name' => 'attendees'],
96 );
97 }
98
99 return $errors;
100 }
101
105 public static function validateDepartmentIds(bool $closed, array $departmentIds): array
106 {
107 $errors = [];
108 if (!$closed && !empty($departmentIds))
109 {
110 $errors[] = new Error(
111 message: 'departments should be empty',
112 code: 'departments_should_be_empty',
113 customData: ['field_name' => 'departmentIds'],
114 );
115 }
116
117 return $errors;
118 }
119}
static validateDescription($description, bool $required=false)
static validateDepartmentIds(bool $closed, array $departmentIds)
Определения error.php:15
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
if(Loader::includeModule( 'bitrix24')) elseif(Loader::includeModule('intranet') &&CIntranetUtils::getPortalZone() !=='ru') $description
Определения .description.php:24
$errors
Определения iblock_catalog_edit.php:74
$name
Определения menu_edit.php:35