antalaron/regex-validator

PHP library to validate regular expressions

v1.0.0 2017-12-01 21:08 UTC

This package is auto-updated.

Last update: 2021-04-16 11:53:37 UTC


README

Build Status Coverage Status Latest Stable Version Latest Unstable Version License

PHP library to validate regular expressions.

Installation

Open a command console, enter your project directory and execute the following command to download the latest stable version of this library:

$ composer require antalaron/regex-validator

This command requires you to have Composer installed globally, as explained in the installation chapter of the Composer documentation.

Basic usage

To validate a regular expression:

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.