API DataValidator_Filters RegExp - chsxf/mfx GitHub Wiki

RegExp Class

chsxf\MFX\DataValidator\Filters

class RegExp extends chsxf\MFX\DataValidator\AbstractFilter

Summary

Descriptor of a filter field based on regular expressions

Since 1.0

Constants

public const REGEX_WORD = '/^[a-z0-9_]+$/i';
public const REGEX_LCWORD = '/^[a-z0-9_]+$/';
public const REGEX_UCWORD = '/^[A-Z0-9_]+$/';
public const REGEX_LCALPHANUMERIC = '/^[a-z0-9]+$/';
public const REGEX_UCALPHANUMERIC = '/^[A-Z0-9]+$/';
public const REGEX_LCHEXADECIMAL = '/^[a-f0-9]+$/';
public const REGEX_UCHEXADECIMAL = '/^[A-F0-9]+$/';
public const REGEX_ICHEXADECIMAL = '/^[a-f0-9]+$/i';
public const REGEX_SQL_DATETIME = '/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/';

Methods

__construct

public function __construct(string $regexp, ?string $message = null)

Constructor

See preg_match()

Since 1.0

Parameters

Name Type Description
$regexp string Perl-Compatible regular expression (PCRE)
$message string Error message

equals

public static function equals(string $value, bool $caseInsensitive = false): RegExp

Helper function to build a equality validation filter

Since 1.0

Parameters

Name Type Description
$value string Exact value to match

Returns

RegExp


hexKey

public static function hexKey(int $bitLength, bool $ignoreCase = false, bool $lowerCase = true): RegExp

Helper function to build variable bit-length hexadecimal key validation filter

Since 1.0

Parameters

Name Type Description
$bitLength int Bit-length of the key (must be a multiple of 8)
$ignoreCase bool If set, produces a case-insensitive validation filter
$lowerCase bool If set and case is not ignored, the validation filter will constrain to lower case. If not set and case is not ignored, the validation filter will constrain to upper case.

Returns

RegExp


lowerCaseWord

public static function lowerCaseWord(): RegExp

Helper function to build lower case validation filter

Since 1.0

Returns

RegExp


stringLength

public static function stringLength(?int $min = null, ?int $max = null): RegExp

Helper function to build string length validation filters

Since 1.0

Parameters

Name Type Description
$min int Minimum required length. If empty or negative, no minimum is required. (Defaults to NULL)
$max int Maximum required length. If empty or negative, no maximum is required. (Defaults to NULL)

Returns

RegExp


upperCaseWord

public static function upperCaseWord(): RegExp

Helper function to build upper case validation filter

Since 1.0

Returns

RegExp


word

public static function word(): RegExp

Helper function to build case-insensitive word validation filter

Since 1.0

Returns

RegExp