RegEx.php
Go to the documentation of this file.
1<?php
7
11class RegEx extends Validator
12{
16 protected $regEx = "//";
17
25 public function validate($value, $parameters = array())
26 {
27 $match = (bool) preg_match($this->regEx, $value, $matchedSubstring);
28
34 $completeMatch = $match && ($value === $matchedSubstring[0]);
35
36 if (preg_last_error() !== PREG_NO_ERROR) {
38 $this->log("Regular expression warning: error code " . preg_last_error());
39 }
40
41 return $completeMatch;
42 }
43
50 public function setRegEx($regEx)
51 {
52 $this->regEx = $regEx;
53 }
54}
customizable validator for input elements
Definition RegEx.php:12
$regEx
regular expression
Definition RegEx.php:16
setRegEx($regEx)
sets the validators regular expression
Definition RegEx.php:50
validate($value, $parameters=array())
validates value with regular expression
Definition RegEx.php:25
log($argument, $type)
error logging method
Definition Validator.php:88
Validators for HTML input-elements.