Regular expression validator
, (*1)
PHP library to validate regular expressions., (*2)
Installation
Open a command console, enter your project directory and execute the
following command to download the latest stable version of this library:, (*3)
$ composer require antalaron/regex-validator
This command requires you to have Composer installed globally, as explained
in the installation chapter
of the Composer documentation., (*4)
Basic usage
To validate a regular expression:, (*5)
use Antalaron\RegexValidator\Regex;
use Symfony\Component\Validator\Validation;
$validator = Validation::createValidator();
$violations = $validator->validate('/foo/', new Regex());
if (0 !== count($violations)) {
foreach ($violations as $violation) {
echo $violation->getMessage().'<br>';
}
}
License
This library is under MIT License., (*6)