https://github.com/antalaron/regex-validator
PHP library to validate regular expressions
https://github.com/antalaron/regex-validator
library php regex-validator regular-expression symfony-validator validation
Last synced: 5 months ago
JSON representation
PHP library to validate regular expressions
- Host: GitHub
- URL: https://github.com/antalaron/regex-validator
- Owner: antalaron
- License: mit
- Created: 2017-12-01T13:08:16.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2022-02-03T13:01:51.000Z (over 4 years ago)
- Last Synced: 2026-01-11T14:20:03.980Z (5 months ago)
- Topics: library, php, regex-validator, regular-expression, symfony-validator, validation
- Language: PHP
- Size: 12.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Regular expression validator
============================
[](https://travis-ci.org/antalaron/regex-validator) [](https://coveralls.io/github/antalaron/regex-validator?branch=master) [](https://packagist.org/packages/antalaron/regex-validator) [](https://packagist.org/packages/antalaron/regex-validator) [](https://packagist.org/packages/antalaron/regex-validator)
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:
```bash
$ composer require antalaron/regex-validator
```
This command requires you to have Composer installed globally, as explained
in the [installation chapter](https://getcomposer.org/doc/00-intro.md)
of the Composer documentation.
Basic usage
-----------
To validate a regular expression:
```php
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().'
';
}
}
```
License
-------
This library is under [MIT License](http://opensource.org/licenses/mit-license.php).