Source of file RegexpRule.php
Size: 0,939 Bytes - Last Modified: 2017-11-08T13:54:24+00:00
/home/travis/build/bluzphp/framework/src/Validator/Rule/RegexpRule.php
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 | <?php /** * Bluz Framework Component * * @copyright Bluz PHP Team * @link https://github.com/bluzphp/framework */ declare(strict_types=1); namespace Bluz\Validator\Rule; /** * Check string by regular expression * * @package Bluz\Validator\Rule */ class RegexpRule extends AbstractRule { /** * @var string error template */ protected $description = 'must validate with regular expression rule'; /** * @var string regular expression for check string */ protected $regexp; /** * Check string by regular expression * * @param string $regexp */ public function __construct($regexp) { $this->regexp = $regexp; } /** * Check string by regular expression * * @param mixed $input * * @return bool */ public function validate($input): bool { return (bool)preg_match($this->regexp, $input); } } |