Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
regexpvalidator.php
1<?php
10
14
15Loc::loadMessages(__FILE__);
16
18{
22 protected $pattern;
23
27 protected $errorPhraseCode = 'MAIN_ENTITY_VALIDATOR_REGEXP';
28
35 public function __construct($pattern, $errorPhrase = null)
36 {
37 if (!is_string($pattern))
38 {
39 throw new ArgumentTypeException('pattern', 'string');
40 }
41
42 $this->pattern = $pattern;
43
44 parent::__construct($errorPhrase);
45 }
46
47
48 public function validate($value, $primary, array $row, ORM\Fields\Field $field)
49 {
50 if (preg_match($this->pattern, $value))
51 {
52 return true;
53 }
54
55 return $this->getErrorMessage($value, $field);
56 }
57}
static loadMessages($file)
Definition loc.php:64
validate($value, $primary, array $row, ORM\Fields\Field $field)
getErrorMessage($value, ORM\Fields\Field $field, $errorPhrase=null, $additionalTemplates=null)
Definition validator.php:50