hylianshield/validator-alphabet

Validator to validate messages against a given alphabet

1.0.1 2017-01-01 15:04 UTC

This package is auto-updated.

Last update: 2024-10-29 04:53:12 UTC


README

The alphabet validator is a validator that will validate given messages against a configured alphabet.

Installation

composer require hylianshield/validator-alphabet:^1.0

Usage

The alphabet validator accepts an alphabet instance. It is based on the PCRE validator.

<?php
use \HylianShield\Alphabet\Alphabet;
use \HylianShield\Validator\Alphabet\AlphabetValidator;

$alphabet  = new Alphabet('A', 'B', 'C');
$validator = new AlphabetValidator($alphabet);

echo $validator->getIdentifier();

Outputs:

pcre(/^[ABC]*$/)

Testing

To run the unit tests, to check the code, simply run one of the pre-configured composer scripts:

  • composer test Runs PHPUnit
  • composer coverage Runs PHPUnit with text coverage
  • composer coverage-html Runs PHPUnit with HTML coverage and opens the result in the browser.