Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
regexpvalidator.php
1
<?php
9
namespace
Bitrix\Main\ORM\Fields\Validators
;
10
11
use
Bitrix\Main\ORM
;
12
use
Bitrix\Main\ArgumentTypeException
;
13
use
Bitrix\Main\Localization\Loc
;
14
15
Loc::loadMessages
(__FILE__);
16
17
class
RegExpValidator
extends
Validator
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
}
Bitrix\Main\ArgumentTypeException
Definition
exception.php:114
Bitrix\Main\Localization\Loc
Definition
loc.php:11
Bitrix\Main\Localization\Loc\loadMessages
static loadMessages($file)
Definition
loc.php:64
Bitrix\Main\ORM\Fields\Field
Definition
field.php:25
Bitrix\Main\ORM\Fields\Validators\RegExpValidator
Definition
regexpvalidator.php:18
Bitrix\Main\ORM\Fields\Validators\RegExpValidator\$errorPhraseCode
$errorPhraseCode
Definition
regexpvalidator.php:27
Bitrix\Main\ORM\Fields\Validators\RegExpValidator\validate
validate($value, $primary, array $row, ORM\Fields\Field $field)
Definition
regexpvalidator.php:48
Bitrix\Main\ORM\Fields\Validators\RegExpValidator\__construct
__construct($pattern, $errorPhrase=null)
Definition
regexpvalidator.php:35
Bitrix\Main\ORM\Fields\Validators\RegExpValidator\$pattern
$pattern
Definition
regexpvalidator.php:22
Bitrix\Main\ORM\Fields\Validators\Validator
Definition
validator.php:18
Bitrix\Main\ORM\Fields\Validators\Validator\getErrorMessage
getErrorMessage($value, ORM\Fields\Field $field, $errorPhrase=null, $additionalTemplates=null)
Definition
validator.php:50
Bitrix\Main\ORM\Fields\Validators\Validator\$errorPhrase
$errorPhrase
Definition
validator.php:23
Bitrix\Main\ORM\Fields\Validators
Definition
booleanvalidator.php:9
Bitrix\Main\ORM
modules
main
lib
orm
fields
validators
regexpvalidator.php
Создано системой
1.10.0