Magento Extensions Rating 2024
EXTENSIONS BY CATEGORY
B2B (Business-To-Business)
Blog
Customer
ERP (Enterprise Resource Planning)
Mega Menu
One Step Checkout
Order
POS (Point Of Sale)
Search
Shopping Cart
Sitemap
SEO
Social
Stock & Inventory Management
EXTENSIONS BY DEVELOPER
aheadWorks
Amasty
Boost My Shop
BSS Commerce
Magestore
MageWorx
Mirasvit
Templates Master
Wyomind
XTENTO
Magento 2 Documentation
Magento 2 Documentation
2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
vendor
magento
zendframework1
library
Zend
Validate
Regex.php
Go to the documentation of this file.
1
<?php
25
#require_once 'Zend/Validate/Abstract.php';
26
33
class
Zend_Validate_Regex
extends
Zend_Validate_Abstract
34
{
35
const
INVALID
=
'regexInvalid'
;
36
const
NOT_MATCH
=
'regexNotMatch'
;
37
const
ERROROUS
=
'regexErrorous'
;
38
42
protected
$_messageTemplates
= array(
43
self::INVALID =>
"Invalid type given. String, integer or float expected"
,
44
self::NOT_MATCH =>
"'%value%' does not match against pattern '%pattern%'"
,
45
self::ERROROUS =>
"There was an internal error while using the pattern '%pattern%'"
,
46
);
47
51
protected
$_messageVariables
= array(
52
'pattern'
=>
'_pattern'
53
);
54
60
protected
$_pattern
;
61
68
public
function
__construct
(
$pattern
)
69
{
70
if
(
$pattern
instanceof
Zend_Config
) {
71
$pattern
=
$pattern
->toArray();
72
}
73
74
if
(is_array(
$pattern
)) {
75
if
(array_key_exists(
'pattern'
,
$pattern
)) {
76
$pattern
=
$pattern
[
'pattern'
];
77
}
else
{
78
#require_once 'Zend/Validate/Exception.php';
79
throw
new
Zend_Validate_Exception
(
"Missing option 'pattern'"
);
80
}
81
}
82
83
$this->
setPattern
(
$pattern
);
84
}
85
91
public
function
getPattern
()
92
{
93
return
$this->_pattern
;
94
}
95
103
public
function
setPattern
(
$pattern
)
104
{
105
$this->_pattern = (string)
$pattern
;
106
$status
= @preg_match($this->_pattern,
"Test"
);
107
108
if
(
false
===
$status
) {
109
#require_once 'Zend/Validate/Exception.php';
110
throw
new
Zend_Validate_Exception
(
"Internal error while using the pattern '$this->_pattern'"
);
111
}
112
113
return
$this;
114
}
115
124
public
function
isValid
(
$value
)
125
{
126
if
(!is_string(
$value
) && !is_int(
$value
) && !is_float(
$value
)) {
127
$this->
_error
(self::INVALID);
128
return
false
;
129
}
130
131
$this->
_setValue
(
$value
);
132
133
$status
= @preg_match($this->_pattern,
$value
);
134
if
(
false
===
$status
) {
135
$this->
_error
(self::ERROROUS);
136
return
false
;
137
}
138
139
if
(!
$status
) {
140
$this->
_error
(self::NOT_MATCH);
141
return
false
;
142
}
143
144
return
true
;
145
}
146
}
Zend_Validate_Regex\getPattern
getPattern()
Definition:
Regex.php:91
$pattern
$pattern
Definition:
website.php:22
Zend_Validate_Regex\setPattern
setPattern($pattern)
Definition:
Regex.php:103
Zend_Validate_Regex\INVALID
const INVALID
Definition:
Regex.php:35
Zend_Validate_Abstract\_error
_error($messageKey, $value=null)
Definition:
Abstract.php:284
Zend_Validate_Regex
Definition:
Regex.php:33
Zend_Validate_Regex\isValid
isValid($value)
Definition:
Regex.php:124
$value
$value
Definition:
gender.phtml:16
Zend_Validate_Abstract
Definition:
Abstract.php:33
Zend_Validate_Abstract\_setValue
_setValue($value)
Definition:
Abstract.php:303
$status
$status
Definition:
order_status.php:8
Zend_Validate_Regex\$_messageVariables
$_messageVariables
Definition:
Regex.php:51
Zend_Validate_Regex\ERROROUS
const ERROROUS
Definition:
Regex.php:37
Zend_Config
Zend_Validate_Regex\$_pattern
$_pattern
Definition:
Regex.php:60
Zend_Validate_Regex\NOT_MATCH
const NOT_MATCH
Definition:
Regex.php:36
Zend_Validate_Exception
Definition:
Exception.php:33
Zend_Validate_Regex\$_messageTemplates
$_messageTemplates
Definition:
Regex.php:42
Zend_Validate_Regex\__construct
__construct($pattern)
Definition:
Regex.php:68