|
- <?php
-
- namespace App\Rules;
-
- class SimpleRegEx extends BaseRule
- {
- /**
- * Create a new rule instance.
- *
- * @return void
- */
- public function __construct(private $pattern, private $message, private $notMatch = false)
- {
- //
- }
-
-
- public function check($value): bool
- {
- $match = preg_match($this->pattern, $value);
- return $this->notMatch ? $match === 0 : $match !== 0;
- }
-
- /**
- * Get the validation error message.
- *
- * @return string
- */
- public function message()
- {
- return $this->message;
- }
- }
|