1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
MaxValidator.php
См. документацию.
1<?php
2
3declare(strict_types=1);
4
5namespace Bitrix\Main\Validation\Validator;
6
7use Bitrix\Main\Localization\LocalizableMessage;
8use Bitrix\Main\Validation\ValidationError;
9use Bitrix\Main\Validation\ValidationResult;
10
12{
13 public function __construct(
14 private readonly int $max
15 )
16 {
17 }
18
19 public function validate(mixed $value): ValidationResult
20 {
22
23 if (!is_numeric($value))
24 {
25 $result->addError(
27 new LocalizableMessage('MAIN_VALIDATION_MAX_NOT_A_NUMBER'),
28 failedValidator: $this
29 )
30 );
31
32 return $result;
33 }
34
35 if ($value > $this->max)
36 {
37 $result->addError(
39 new LocalizableMessage('MAIN_VALIDATION_MAX_GREATER_THAN_MAX', ['#MAX#' => $this->max]),
40 failedValidator: $this
41 )
42 );
43
44 return $result;
45 }
46
47 return $result;
48 }
49}
__construct(private readonly int $max)
Определения MaxValidator.php:13
$result
Определения get_property_values.php:14
$max
Определения template_copy.php:262