for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Fiv\Form\Validator;
/**
* @author Ivan Shcherbak <[email protected]> 7/11/14
*/
class Regexp extends Base {
* @var string
protected $error = 'Invalid value';
protected $regexp = '';
* @param string $regexp
* @return $this
public function setRegexp($regexp) {
$this->regexp = $regexp;
return $this;
}
* @param string $error
public function setError($error) {
$this->error = $error;
* @param string $value
* @return bool
public function isValid($value) {
if (!empty($this->regexp) and !preg_match($this->regexp, $value)) {
$this->addError($this->error);
return !$this->hasErrors();