| 1 |
<?php |
| 2 |
/** |
| 3 |
* PFBC (PHP Form Builder Class) - Third-party library |
| 4 |
* @package PFBC |
| 5 |
*/ |
| 6 |
|
| 7 |
// phpcs:disable WordPress.Security.EscapeOutput, WordPress.NamingConventions.PrefixAllGlobals, PluginCheck.CodeAnalysis.Heredoc -- Third-party library |
| 8 |
|
| 9 |
class Validation_RegExp extends Validation { |
| 10 |
protected $message = "Error: %element% contains invalid characters."; |
| 11 |
protected $pattern; |
| 12 |
|
| 13 |
public function __construct($pattern, $message = "") { |
| 14 |
$this->pattern = $pattern; |
| 15 |
parent::__construct($message); |
| 16 |
} |
| 17 |
|
| 18 |
public function isValid($value) { |
| 19 |
if($this->isNotApplicable($value) || preg_match($this->pattern, $value)) |
| 20 |
return true; |
| 21 |
return false; |
| 22 |
} |
| 23 |
} |
| 24 |
|