Validation
class Validation extends Expression (View source)
Validator aware validation expression builder.
{@inheritDoc}
Example:
$validation = (new Validation())->required()->string()->between(2, 255)->or()->null();
$validation = Validation::required()->string()->between(2, 255)->or()->null()->build();
Rules:
Constants
BEHAVIORS |
Expression behaviors. |
OPERATORS |
Expression operators. |
Properties
protected string | $buffer | Expression string buffer. |
from Expression |
protected array | $tokens | Expression string buffer tokens. |
from Expression |
protected Validator|null | $validator | Associated Validator instance. |
Methods
Provides rules and aliases as class methods.
Provides rules and aliases as static class methods.
Validation constructor.
note that strings are treated in a case-insensitive manner.
Adds a validation string or object as a group to the current validation expression.
.
Adds alnum
rule. Asserts that the input consists of alphanumeric characters only.
Adds alpha
rule. Asserts that the input consists of alphabetic characters only.
.
Adds amount.dollar
rule. Asserts that the input is a validly formatted amount of USD, where decimal point and thousands separator are optional.
Adds amount.euro
rule. Asserts that the input is a validly formatted amount of EUR, where decimal point and thousands separator are optional.
Adds AND operator (ampersand: &
) (default). Ands the next rule/group.
Adds arr
rule. An alias for the array
rule.
Adds array
rule. Asserts that the input is an array.
Adds array.hasDistinct
rule. Asserts that the input is a multidimensional array that contains distinct values of the given key.
Adds array.hasKey
rule. Asserts that the input array has the given key.
Adds array.hasValue
rule. Asserts that the input array contains the given value. Works with scalar types.
Adds array.isAssociative
rule. Asserts that the input is an associative array.
Adds array.isSequential
rule. Asserts that the input is a sequential array.
Adds array.isUnique
rule. Asserts that the input array contains unique values. Works only with one-dimensional arrays.
Adds array.subset
rule. Asserts that the input is an array that contains the given subset. Note that this check applies only to the first dimension of the array.
.
Adds assert
rule. An alias for the if
rule.
Adds assert.equals
rule. An alias for the if.eq
rule.
Adds assert.greaterThan
rule. An alias for the if.gt
rule.
Adds assert.greaterThanOrEquals
rule. An alias for the if.gte
rule.
Adds assert.lessThan
rule. An alias for the if.lt
rule.
Adds assert.lessThanOrEquals
rule. An alias for the if.lte
rule.
Adds assert.notEquals
rule. An alias for the if.neq
rule.
Adds base64
rule. Asserts that the input is a valid Base64 encoded string.
.
.
.
.
.
Adds blank
rule. An alias for the empty
rule.
Adds bool
rule. An alias for the boolean
rule.
Adds boolean
rule. Asserts that the input is a boolean.
.
Adds cakeday
rule. An alias for the datetime.birthday
rule.
.
.
Adds callable
rule. Asserts that the input is a callable.
Writes a rule to the current validation expression that executes the passed callback.
Adds choice
rule. An alias for the in
rule.
Adds CLOSE operator (closing parenthesis: )
). Ends the current group.
Adds cntrl
rule. Asserts that the input consists of control characters only.
.
Adds color.hex
rule. Asserts that the input is a valid CSS HEX color.
color.
Adds color.hexLong
rule. Asserts that the input is a valid CSS 6-Char-HEX color.
Adds color.hexShort
rule. Asserts that the input is a valid CSS 3-Char-HEX color.
Adds color.hsl
rule. Asserts that the input is a valid CSS HSL color.
Adds color.hsl.new
rule. Asserts that the input is a valid CSS4 HSL color.
Adds color.hsla
rule. Asserts that the input is a valid CSS HSLA color.
Adds color.keyword
rule. Asserts that the input is a valid CSS YYY color.
Adds color.rgb
rule. Asserts that the input is a valid CSS RGB color.
Adds color.rgb.new
rule. Asserts that the input is a valid CSS4 RGB color.
Adds color.rgba
rule. Asserts that the input is a valid CSS RGBA color.
Writes the passed string to the current expression string buffer.
.
Adds countable
rule. Asserts that the input is a countable.
.
Returns a valid rule statement from the passed name and arguments.
Adds creditcard
rule. Asserts that the input is a valid credit card number, balanced spaces and/or dashes are allowed.
Adds creditcard.americanExpress
rule. Asserts that the input is a valid American Express credit card number, balanced spaces and/or dashes are allowed.
Adds creditcard.chinaUnionPay
rule. Asserts that the input is a valid China UnionPay credit card number, balanced spaces and/or dashes are allowed.
Adds creditcard.dinersClub
rule. Asserts that the input is a valid Diners Club credit card number, balanced spaces and/or dashes are allowed.
Adds creditcard.discover
rule. Asserts that the input is a valid Discover credit card number, balanced spaces and/or dashes are allowed.
Adds creditcard.instaPayment
rule. Asserts that the input is a valid InstaPayment credit card number, balanced spaces and/or dashes are allowed.
Adds creditcard.jcb
rule. Asserts that the input is a valid JCB credit card number, balanced spaces and/or dashes are allowed.
Adds creditcard.laser
rule. Asserts that the input is a valid Laser credit card number, balanced spaces and/or dashes are allowed.
Adds creditcard.maestro
rule. Asserts that the input is a valid Maestro credit card number, balanced spaces and/or dashes are allowed.
Adds creditcard.mastercard
rule. Asserts that the input is a valid Mastercard credit card number, balanced spaces and/or dashes are allowed.
Adds creditcard.mir
rule. Asserts that the input is a valid MIR Payment System card number, balanced spaces and/or dashes are allowed.
Adds creditcard.uatp
rule. Asserts that the input is a valid UATP credit card number, balanced spaces and/or dashes are allowed.
Adds creditcard.visa
rule. Asserts that the input is a valid Visa credit card number, balanced spaces and/or dashes are allowed.
.
.
.
Adds date
rule. An alias for the datetime
rule.
Adds date.after
rule. An alias for the datetime.gt
rule.
Adds date.afterOrEquals
rule. An alias for the datetime.gte
rule.
Adds date.before
rule. An alias for the datetime.lt
rule.
Adds date.beforeOrEquals
rule. An alias for the datetime.lte
rule.
Adds date.equals
rule. An alias for the datetime.eq
rule.
Adds date.format
rule. An alias for the datetime.format
rule.
Adds datestamp
rule. Asserts that the input looks like a human datestamp, DMY or MDY format, separated with dot, dash, or slash.
Adds datestamp.dmy
rule. Asserts that the input looks like a human DMY-formatted datestamp, separated with dot, dash, or slash.
Adds datestamp.mdy
rule. Asserts that the input looks like a human MDY-formatted datestamp, separated with dot, dash, or slash.
Adds datestamp.ymd
rule. Asserts that the input looks like a human YMD-formatted datestamp, separated with dot, dash, or slash.
Adds datetime
rule. Asserts that the input is a valid datetime string/object.
Adds datetime.birthday
rule. Asserts that the input is a datetime string/object that has birthday today. Input should preferably be in "YYYY-MM-DD" format.
Adds datetime.eq
rule. Asserts that the input is a datetime string/object equal to the given datetime string.
Adds datetime.format
rule. Asserts that the input is a valid datetime with the given format.
Adds datetime.format.global
rule. Asserts that the input looks like a valid global datetime string as defined in the HTML5 specification.
Adds datetime.format.local
rule. Asserts that the input looks like a valid local datetime string as defined in the HTML5 specification.
the given datetime string.
or equal to the given datetime string.
the given datetime string.
or equal to the given datetime string.
note that strings are treated in a case-insensitive manner.
.
Adds domain
rule. Asserts that the input is a domain.
Adds domain.isActive
rule. Asserts that the input is an active domain. Works with domains and emails.
Adds double
rule. An alias for the float
rule.
Adds email
rule. Asserts that the input is an email address.
.
Adds emoji
rule. Asserts that the input contains an emoji.
.
Adds equals
rule. Asserts that the input is equal to the given value. Works with scalar types and null. Comparison operator is "==".
.
.
Adds file.basename
rule. Asserts that the input is a file and its basename is equal to the given basename.
Adds file.dirname
rule. Asserts that the input is a file and its dirname is equal to the given dirname.
Adds file.extension
rule. Asserts that the input is a file and its extension is equal to the given extension.
Adds file.filename
rule. Asserts that the input is a file and its filename is equal to the given filename.
Adds file.isDirectory
rule. Asserts that the input is a directory.
Adds file.isExecutable
rule. Asserts that the input is a file and is executable.
Adds file.isFile
rule. Asserts that the input is a file.
Adds file.isLink
rule. Asserts that the input is a link.
Adds file.isReadable
rule. Asserts that the input is a file and is readable.
Adds file.isUploaded
rule. Asserts that the input is a file that is uploaded via HTTP POST.
Adds file.isWritable
rule. Asserts that the input is a file and is writable.
Adds file.mime
rule. Asserts that the input is a file and its MIME type is one of the given MIME types.
Adds file.size
rule. Asserts that the input is a file and the size is equal to the given size in bytes.
Adds file.size.gte
rule. Asserts that the input is a file and the size is greater than or equal to the given size in bytes.
Adds file.size.lte
rule. Asserts that the input is a file and the size is less than or equal to the given size in bytes.
Adds filled
rule. An alias for the required
rule.
Adds float
rule. Asserts that the input is a float.
Adds floatLike
rule. Asserts that the input is a value that can be parsed as a float within the specifed range.
Adds floatLike.allowThousands
rule. Asserts that the input is a value that can be parsed as a float within the specifed range.
.
.
Returns a consistent hash for the rule name.
Returns an associative array of rule names and their corresponding hashes.
.
Groups a set of rules inside a pair of parentheses ()
.
. The "ISO 3166-1 alpha-2" country code can be specifed to narrow the pattern.
Adds if
rule. Checks the condition between the first argument and the second argument, the condition operator can also be specified as the third argument.
Adds if.eq
rule. Checks the condition between the first argument and the second argument, the condition operator is "==".
Adds if.gt
rule. Checks the condition between the first argument and the second argument, the condition operator is ">".
Adds if.gte
rule. Checks the condition between the first argument and the second argument, the condition operator is ">=".
Adds if.id
rule. Checks the condition between the first argument and the second argument, the condition operator is "===".
Adds if.lt
rule. Checks the condition between the first argument and the second argument, the condition operator is "<".
Adds if.lte
rule. Checks the condition between the first argument and the second argument, the condition operator is "<=".
Adds if.neq
rule. Checks the condition between the first argument and the second argument, the condition operator is "!=".
Adds if.nid
rule. Checks the condition between the first argument and the second argument, the condition operator is "!==".
.
Adds image.dimensions
rule. Asserts that the input is an image and its dimensions are less than, equal to, or greater than the given width and height in pixels.
Adds image.height
rule. Asserts that the input is an image and its height is equal to the given height in pixels.
Adds image.height.gte
rule. Asserts that the input is an image and its height is greater than or equal to the given height in pixels.
Adds image.height.lte
rule. Asserts that the input is an image and its height is less than or equal to the given height in pixels.
.
Adds image.width
rule. Asserts that the input is an image and its width is equal to the given width in pixels.
Adds image.width.gte
rule. Asserts that the input is an image and its width is greater than or equal to the given width in pixels.
Adds image.width.lte
rule. Asserts that the input is an image and its width is less than or equal to the given width in pixels.
.
.
Adds in
rule. Asserts that the input is in the given values. Works with scalar types and null.
Adds int
rule. An alias for the integer
rule.
Adds integer
rule. Asserts that the input is an integer.
Adds integerLike
rule. Asserts that the input is a value that can be parsed as an integer within the specifed range.
Adds integerLike.allowHex
rule. Asserts that the input is a value that can be parsed as an integer within the specifed range and can be in hexadecimal notation.
Adds integerLike.allowOctal
rule. Asserts that the input is a value that can be parsed as an integer within the specifed range and can be in octal notation.
Adds ip
rule. Asserts that the input is an IP address.
Adds ip.notPrivate
rule. Asserts that the input is an IP address not within private IPs range.
Adds ip.notReserved
rule. Asserts that the input is an IP address not within reserved IPs range.
Adds ip.v4
rule. Asserts that the input is an IPv4 address.
Adds ip.v6
rule. Asserts that the input is an IPv6 address.
Adds is
rule. An alias for the equals
rule.
can be specifed to narrow the pattern.
.
.
Adds iterable
rule. Asserts that the input is an iterable.
Adds json
rule. Asserts that the input is a valid JSON.
.
Adds length
rule. An alias for the count
rule.
; strict: [ISO 639-1] or [ISO 639-1]_[ISO 3166-1 alpha-2], case-sensitive without canonicalization.
Adds long
rule. An alias for the integer
rule.
Adds lower
rule. Asserts that the input consists of lowercase characters only.
Adds luhn
rule. Asserts that the input passes the Luhn Algorithm check. This rule is mostly used in conjunction with other rules like credit card numbers and identifiers to further check the validity of the subject.
Adds mac
rule. Asserts that the input is a MAC address.
Adds matches
rule. Asserts that the input matches the given pattern. Works with strings only.
.
.
.
.
Adds minmax
rule. An alias for the between
rule.
Creates a new Validation instance that is bound to the default Validator.
.
Makes the expression normal (executes all checks). The is the default behavior.
Adds null
rule. Asserts that the input is null.
Adds number.isEven
rule. Asserts that the input is an even number.
Adds number.isFinite
rule. Asserts that the input is a finite number.
Adds number.isInfinite
rule. Asserts that the input is an infinite number.
Adds number.isMultipleOf
rule. Asserts that the input is a multiple of the given number.
Adds number.isNan
rule. Asserts that the input is a not a number.
Adds number.isNegative
rule. Asserts that the input is a negative number.
Adds number.isOdd
rule. Asserts that the input is an odd number.
Adds number.isPositive
rule. Asserts that the input is a positive number.
Adds numeric
rule. Asserts that the input is numeric.
Adds obj
rule. An alias for the object
rule.
Adds object
rule. Asserts that the input is an object.
Adds object.hasMethod
rule. Asserts that the input has the given method.
Adds object.hasProperty
rule. Asserts that the input has the given property.
Adds object.isInstanceOf
rule. Asserts that the input is an instance of the given class.
method.
Adds object.isSubclassOf
rule. Asserts that the input is a subclass of the given class.
Makes the expression optimistic (stop checking after first success).
Adds optional
rule. An alias for the allowed
rule.
.
Adds pattern
rule. An alias for the matches
rule.
Makes the expression pessimistic (stop checking after first failure).
.
Adds php.keyword
rule. Asserts that the input is a PHP language Keyword.
Adds php.reserved
rule. Asserts that the input is a PHP language reserved word.
Adds php.reserved.extra
rule. Asserts that the input is a PHP language reserved word including soft reserved words.
Adds present
rule. An alias for the required
rule.
Adds print
rule. Asserts that the input consists of printable characters only.
Adds punct
rule. Asserts that the input consists of punctuation characters only.
Adds range
rule. An alias for the between
rule.
Adds real
rule. An alias for the float
rule.
Adds regexp
rule. Asserts that the input matches a Perl-compatible regular expression.
.
Adds resource
rule. Asserts that the input is a resource.
Adds roman
rule. Asserts that the input is a valid roman number.
Adds same
rule. An alias for the equals
rule.
Adds scalar
rule. Asserts that the input is a scalar.
Adds serialized
rule. Asserts that the input is a valid PHP serialized data.
.
Adds size
rule. An alias for the count
rule.
Adds slug
rule. Asserts that the input is a valid slug.
Adds space
rule. Asserts that the input consists of whitespace characters only.
Adds spaceless
rule. Asserts that the input is a string containing no whitespace characters.
.
Adds str
rule. An alias for the string
rule.
Adds stream
rule. An alias for the resource
rule.
Adds string
rule. Asserts that the input is a string.
. The check is done in a case-sensitive manner.
.
.
Adds string.length
rule. Asserts that the input is a string that is exactly the given length.
.
Adds string.wordsCount
rule. Asserts that the input is a string containing exactly the given count of words.
Adds text
rule. Asserts that the input is a string containing letters and punctuation from any language.
Adds timestamp
rule. Asserts that the input looks like a human timestamp, 24 or 12 hours format with or without seconds.
Adds timestamp.12
rule. Asserts that the input looks like a human timestamp, 12 hours format with or without seconds and optional AM/PM..
Adds timestamp.hm
rule. Asserts that the input looks like a human timestamp, 24 or 12 hours format without seconds.
Adds timestamp.hms
rule. Asserts that the input looks like a human timestamp, 24 or 12 hours format with seconds.
Adds timestamp.ms
rule. Asserts that the input looks like a human timestamp, containing minutes and seconds only.
.
Adds type
rule. Asserts that the input is one of the given types.
.
Adds upper
rule. Asserts that the input consists of uppercase characters only.
Adds url
rule. Asserts that the input is a URL.
Adds url.withPath
rule. Asserts that the input is a URL that contains a path.
Adds url.withQuery
rule. Asserts that the input is a URL that contains a query.
.
can be specifed to narrow the pattern.
Returns a the passed key as a valid back-reference injectable.
Adds version
rule. Asserts that the input is a valid semantic version number.
.
Adds words
rule. Asserts that the input is a string containing only words and spaces without any other character.
Writes the passed string to the current expression string buffer.
Adds xdigit
rule. Asserts that the input represent hexadecimal digits.
Adds xml
rule. Asserts that the input is a valid XML.
Details
mixed
__call(string $name, array $arguments)
Provides rules and aliases as class methods.
static mixed
__callStatic(string $name, array $arguments)
Provides rules and aliases as static class methods.
__construct(Validator|null $validator = null)
Validation constructor.
string
__toString()
Returns the current expression string.
static static
accepted() $dds `accepted` rule. Asserts that the input is accepted (equals: "on", "aye" $, 1 $r "1", true $r "true")
note that strings are treated in a case-insensitive manner.
Validation
add(Expression $validation)
Adds a validation string or object as a group to the current validation expression.
static static
allowed() $dds `allowed` rule. Asserts that the input is allowed (can be empty or have any value, null $nd empty string are considered valid values)
.
static static
alnum()
Adds alnum
rule. Asserts that the input consists of alphanumeric characters only.
static static
alpha()
Adds alpha
rule. Asserts that the input consists of alphabetic characters only.
static static
amount() $dds `amount` rule. Asserts that the input contains only numbers, an $ptional decimal point (comma or dot), and $n optional minus (used for amounts of money for example)
.
static static
amountDollar()
Adds amount.dollar
rule. Asserts that the input is a validly formatted amount of USD, where decimal point and thousands separator are optional.
static static
amountEuro()
Adds amount.euro
rule. Asserts that the input is a validly formatted amount of EUR, where decimal point and thousands separator are optional.
Expression
and()
Adds AND operator (ampersand: &
) (default). Ands the next rule/group.
static static
arr()
Adds arr
rule. An alias for the array
rule.
static static
array()
Adds array
rule. Asserts that the input is an array.
static static
arrayHasDistinct(string|int $key)
Adds array.hasDistinct
rule. Asserts that the input is a multidimensional array that contains distinct values of the given key.
static static
arrayHasKey(string|int $key)
Adds array.hasKey
rule. Asserts that the input array has the given key.
static static
arrayHasValue(mixed $value)
Adds array.hasValue
rule. Asserts that the input array contains the given value. Works with scalar types.
static static
arrayIsAssociative()
Adds array.isAssociative
rule. Asserts that the input is an associative array.
static static
arrayIsSequential()
Adds array.isSequential
rule. Asserts that the input is a sequential array.
static static
arrayIsUnique()
Adds array.isUnique
rule. Asserts that the input array contains unique values. Works only with one-dimensional arrays.
static static
arraySubset(array $subset)
Adds array.subset
rule. Asserts that the input is an array that contains the given subset. Note that this check applies only to the first dimension of the array.
static static
ascii() $dds `ascii` rule. Asserts that the input is a string containing only ASCII characters (ASCII compliant string)
.
static static
assert(mixed $actual, mixed $expected = true, string $operator = '==')
Adds assert
rule. An alias for the if
rule.
static static
assertEquals(mixed $actual, mixed $expected)
Adds assert.equals
rule. An alias for the if.eq
rule.
static static
assertGreaterThan(mixed $actual, mixed $expected)
Adds assert.greaterThan
rule. An alias for the if.gt
rule.
static static
assertGreaterThanOrEquals(mixed $actual, mixed $expected)
Adds assert.greaterThanOrEquals
rule. An alias for the if.gte
rule.
static static
assertLessThan(mixed $actual, mixed $expected)
Adds assert.lessThan
rule. An alias for the if.lt
rule.
static static
assertLessThanOrEquals(mixed $actual, mixed $expected)
Adds assert.lessThanOrEquals
rule. An alias for the if.lte
rule.
static static
assertNotEquals(mixed $actual, mixed $expected)
Adds assert.notEquals
rule. An alias for the if.neq
rule.
static static
base64()
Adds base64
rule. Asserts that the input is a valid Base64 encoded string.
static static
between(int|float $min, int|float $max) Adds `between` rule. Asserts that the input count is between the given values. Works with all data types (null: 0; boolean: 0 or 1; float/integer: number value; string: characters count; array/countable: elements count; object: accessible properties count)
.
static static
bic() $dds `bic` rule. Asserts that the input is a valid BIC (Bank Identifier Code)
.
static static
bit() $dds `bit` rule. Asserts that the input is bit (equals: 1 or "1", true; $or "0", false $)
.
static static
bitIsOff() $dds `bit.isOff` rule. Asserts that the input is a turned off bit (equals: false, $r "0")
.
static static
bitIsOn() $dds `bit.isOn` rule. Asserts that the input is a turned on bit (equals: true, 1 $r "1")
.
static static
blank()
Adds blank
rule. An alias for the empty
rule.
static static
bool()
Adds bool
rule. An alias for the boolean
rule.
static static
boolean()
Adds boolean
rule. Asserts that the input is a boolean.
static static
booleanLike() $dds `booleanLike` rule. Asserts that the input is value that can be parsed as a boolean (TRUE: true, null $, "yes"; $ALSE: false)
.
string
build()
Returns the current expression string.
static static
cakeday()
Adds cakeday
rule. An alias for the datetime.birthday
rule.
static static
calenderDay() $dds `calender.day` rule. Asserts that the input looks like a calendar dayin shot or long format ("Mon" or "Monday")
.
static static
calenderMonth() $dds `calender.month` rule. Asserts that the input looks like a calendar month in shot or long format ("Jan" or "January")
.
static static
callable()
Adds callable
rule. Asserts that the input is a callable.
Validation
callback(callable $callback, string|null $id = null)
Writes a rule to the current validation expression that executes the passed callback.
static static
choice(string|int|float|bool|null $values)
Adds choice
rule. An alias for the in
rule.
Expression
close()
Adds CLOSE operator (closing parenthesis: )
). Ends the current group.
static static
cntrl()
Adds cntrl
rule. Asserts that the input consists of control characters only.
static static
color() $dds `color` rule. Asserts that the input is a valid CSS color (Color Word, HSLA $)
.
static static
colorHex()
Adds color.hex
rule. Asserts that the input is a valid CSS HEX color.
static static
colorHexAlpha() $dds `color.hexAlpha` rule. Asserts that the input is a valid CSS HEX-Alpha (4 or 8 Chars)
color.
static static
colorHexLong()
Adds color.hexLong
rule. Asserts that the input is a valid CSS 6-Char-HEX color.
static static
colorHexShort()
Adds color.hexShort
rule. Asserts that the input is a valid CSS 3-Char-HEX color.
static static
colorHsl()
Adds color.hsl
rule. Asserts that the input is a valid CSS HSL color.
static static
colorHslNew()
Adds color.hsl.new
rule. Asserts that the input is a valid CSS4 HSL color.
static static
colorHsla()
Adds color.hsla
rule. Asserts that the input is a valid CSS HSLA color.
static static
colorKeyword()
Adds color.keyword
rule. Asserts that the input is a valid CSS YYY color.
static static
colorRgb()
Adds color.rgb
rule. Asserts that the input is a valid CSS RGB color.
static static
colorRgbNew()
Adds color.rgb.new
rule. Asserts that the input is a valid CSS4 RGB color.
static static
colorRgba()
Adds color.rgba
rule. Asserts that the input is a valid CSS RGBA color.
static string
comment(string $text)
Returns a the passed string as a valid comment.
Expression
concat(string $string)
Writes the passed string to the current expression string buffer.
Note that the necessary operators will NOT be added automatically (use self::write()
instead).
Note that this method may make the expression fail when build if it is malformed.
static static
count(int $count) Adds `count` rule. Asserts that the input count is equal to the given value. Works with all data types (null: 0; boolean: 0 or 1; float/integer: number value; string: characters count; array/countable: elements count; object: accessible properties count)
.
static static
countable()
Adds countable
rule. Asserts that the input is a countable.
static static
country(bool $long = false) Adds `country` rule. Asserts that the input is a valid country code (default: "ISO 3166-1 alpha-2"; long: "ISO 3166-1 alpha-3")
.
protected string
createRuleStatement(string $name, array $arguments)
Returns a valid rule statement from the passed name and arguments.
static static
creditcard()
Adds creditcard
rule. Asserts that the input is a valid credit card number, balanced spaces and/or dashes are allowed.
static static
creditcardAmericanExpress()
Adds creditcard.americanExpress
rule. Asserts that the input is a valid American Express credit card number, balanced spaces and/or dashes are allowed.
static static
creditcardChinaUnionPay()
Adds creditcard.chinaUnionPay
rule. Asserts that the input is a valid China UnionPay credit card number, balanced spaces and/or dashes are allowed.
static static
creditcardDinersClub()
Adds creditcard.dinersClub
rule. Asserts that the input is a valid Diners Club credit card number, balanced spaces and/or dashes are allowed.
static static
creditcardDiscover()
Adds creditcard.discover
rule. Asserts that the input is a valid Discover credit card number, balanced spaces and/or dashes are allowed.
static static
creditcardInstaPayment()
Adds creditcard.instaPayment
rule. Asserts that the input is a valid InstaPayment credit card number, balanced spaces and/or dashes are allowed.
static static
creditcardJcb()
Adds creditcard.jcb
rule. Asserts that the input is a valid JCB credit card number, balanced spaces and/or dashes are allowed.
static static
creditcardLaser()
Adds creditcard.laser
rule. Asserts that the input is a valid Laser credit card number, balanced spaces and/or dashes are allowed.
static static
creditcardMaestro()
Adds creditcard.maestro
rule. Asserts that the input is a valid Maestro credit card number, balanced spaces and/or dashes are allowed.
static static
creditcardMastercard()
Adds creditcard.mastercard
rule. Asserts that the input is a valid Mastercard credit card number, balanced spaces and/or dashes are allowed.
static static
creditcardMir()
Adds creditcard.mir
rule. Asserts that the input is a valid MIR Payment System card number, balanced spaces and/or dashes are allowed.
static static
creditcardUatp()
Adds creditcard.uatp
rule. Asserts that the input is a valid UATP credit card number, balanced spaces and/or dashes are allowed.
static static
creditcardVisa()
Adds creditcard.visa
rule. Asserts that the input is a valid Visa credit card number, balanced spaces and/or dashes are allowed.
static static
currency(bool $numeric = false) Adds `currency` rule. Asserts that the input is a valid currency code (default: "ISO 4217 alpha"; numeric: "ISO 4217 numeric")
.
static static
currencyName() $dds `currency.name` rule. Asserts that the input is a valid currency name (as in ISO 4217)
.
static static
cvv() $dds `cvv` rule. Asserts that the input is a valid CVV (Card Security Code)
.
static static
date()
Adds date
rule. An alias for the datetime
rule.
static static
dateAfter(string $datetime)
Adds date.after
rule. An alias for the datetime.gt
rule.
static static
dateAfterOrEquals(string $datetime)
Adds date.afterOrEquals
rule. An alias for the datetime.gte
rule.
static static
dateBefore(string $datetime)
Adds date.before
rule. An alias for the datetime.lt
rule.
static static
dateBeforeOrEquals(string $datetime)
Adds date.beforeOrEquals
rule. An alias for the datetime.lte
rule.
static static
dateEquals(string $datetime)
Adds date.equals
rule. An alias for the datetime.eq
rule.
static static
dateFormat(string $format)
Adds date.format
rule. An alias for the datetime.format
rule.
static static
datestamp()
Adds datestamp
rule. Asserts that the input looks like a human datestamp, DMY or MDY format, separated with dot, dash, or slash.
static static
datestampDmy()
Adds datestamp.dmy
rule. Asserts that the input looks like a human DMY-formatted datestamp, separated with dot, dash, or slash.
static static
datestampMdy()
Adds datestamp.mdy
rule. Asserts that the input looks like a human MDY-formatted datestamp, separated with dot, dash, or slash.
static static
datestampYmd()
Adds datestamp.ymd
rule. Asserts that the input looks like a human YMD-formatted datestamp, separated with dot, dash, or slash.
static static
datetime()
Adds datetime
rule. Asserts that the input is a valid datetime string/object.
static static
datetimeBirthday()
Adds datetime.birthday
rule. Asserts that the input is a datetime string/object that has birthday today. Input should preferably be in "YYYY-MM-DD" format.
static static
datetimeEq(string $datetime)
Adds datetime.eq
rule. Asserts that the input is a datetime string/object equal to the given datetime string.
static static
datetimeFormat(string $format)
Adds datetime.format
rule. Asserts that the input is a valid datetime with the given format.
static static
datetimeFormatGlobal()
Adds datetime.format.global
rule. Asserts that the input looks like a valid global datetime string as defined in the HTML5 specification.
static static
datetimeFormatLocal()
Adds datetime.format.local
rule. Asserts that the input looks like a valid local datetime string as defined in the HTML5 specification.
static static
datetimeGt(string $datetime) Adds `datetime.gt` rule. Asserts that the input is a datetime string/object greater than (after)
the given datetime string.
static static
datetimeGte(string $datetime) Adds `datetime.gte` rule. Asserts that the input is a datetime string/object greater than (after)
or equal to the given datetime string.
static static
datetimeLt(string $datetime) Adds `datetime.lt` rule. Asserts that the input is a datetime string/object less than (before)
the given datetime string.
static static
datetimeLte(string $datetime) Adds `datetime.lte` rule. Asserts that the input is a datetime string/object less than (before)
or equal to the given datetime string.
static static
declined() $dds `declined` rule. Asserts that the input is declined (equals: "off", "nay" $, $r "0", false $r "false")
note that strings are treated in a case-insensitive manner.
static static
digit() $dds `digit` rule. Asserts that the input consists of a digits only (numeric characters)
.
static static
domain()
Adds domain
rule. Asserts that the input is a domain.
static static
domainIsActive()
Adds domain.isActive
rule. Asserts that the input is an active domain. Works with domains and emails.
static static
double()
Adds double
rule. An alias for the float
rule.
static static
email()
Adds email
rule. Asserts that the input is an email address.
static static
emailWithUnicode() $dds `email.withUnicode` rule. Asserts that the input is an email address (unicode allowed)
.
static static
emoji()
Adds emoji
rule. Asserts that the input contains an emoji.
static static
empty() $dds `empty` rule. Asserts that the input is empty using empty() language construct (is blank, i.e. $mpty string, empty $rray, or $)
.
static static
equals(string|int|float|bool|null $value)
Adds equals
rule. Asserts that the input is equal to the given value. Works with scalar types and null. Comparison operator is "==".
static static
esn() $dds `esn` rule. Asserts that the input is a valid ESN (Electronic Serial Number)
.
static static
file() $dds `file` rule. Asserts that the input is a file (can be a file, a $ink, or $directory)
.
static static
fileBasename(string $basename)
Adds file.basename
rule. Asserts that the input is a file and its basename is equal to the given basename.
static static
fileDirname(string $dirname)
Adds file.dirname
rule. Asserts that the input is a file and its dirname is equal to the given dirname.
static static
fileExtension(string $extension)
Adds file.extension
rule. Asserts that the input is a file and its extension is equal to the given extension.
static static
fileFilename(string $filename)
Adds file.filename
rule. Asserts that the input is a file and its filename is equal to the given filename.
static static
fileIsDirectory()
Adds file.isDirectory
rule. Asserts that the input is a directory.
static static
fileIsExecutable()
Adds file.isExecutable
rule. Asserts that the input is a file and is executable.
static static
fileIsFile()
Adds file.isFile
rule. Asserts that the input is a file.
static static
fileIsLink()
Adds file.isLink
rule. Asserts that the input is a link.
static static
fileIsReadable()
Adds file.isReadable
rule. Asserts that the input is a file and is readable.
static static
fileIsUploaded()
Adds file.isUploaded
rule. Asserts that the input is a file that is uploaded via HTTP POST.
static static
fileIsWritable()
Adds file.isWritable
rule. Asserts that the input is a file and is writable.
static static
fileMime(string|array $mine)
Adds file.mime
rule. Asserts that the input is a file and its MIME type is one of the given MIME types.
static static
fileSize(int $sizeInBytes)
Adds file.size
rule. Asserts that the input is a file and the size is equal to the given size in bytes.
static static
fileSizeGte(int $sizeInBytes)
Adds file.size.gte
rule. Asserts that the input is a file and the size is greater than or equal to the given size in bytes.
static static
fileSizeLte(int $sizeInBytes)
Adds file.size.lte
rule. Asserts that the input is a file and the size is less than or equal to the given size in bytes.
static static
filled()
Adds filled
rule. An alias for the required
rule.
static static
float()
Adds float
rule. Asserts that the input is a float.
static static
floatLike(float $min = PHP_FLOAT_MIN, float $max = PHP_FLOAT_MAX)
Adds floatLike
rule. Asserts that the input is a value that can be parsed as a float within the specifed range.
static static
floatLikeAllowThousands(float $min = PHP_FLOAT_MIN, float $max = PHP_FLOAT_MAX)
Adds floatLike.allowThousands
rule. Asserts that the input is a value that can be parsed as a float within the specifed range.
static static
forbidden() $dds `forbidden` rule. Asserts that the input is forbidden (is null or not present)
.
static static
geolocation() $dds `geolocation` rule. Asserts that the input is a valid geolocation (latitude and longitude coordinates combination)
.
private string
getBehaviorChars()
No description
private string
getHashedName(string $name)
Returns a consistent hash for the rule name.
private array
getHashedNames()
Returns an associative array of rule names and their corresponding hashes.
private array
getOperatorChars()
No description
static static
graph() $dds `graph` rule. Asserts that the input consists of graphic characters only (characters that create a visible output)
.
Expression
group(callable $callback)
Groups a set of rules inside a pair of parentheses ()
.
static static
iban(?string $country = null) Adds `iban` rule. Asserts that the input is a valid IBAN (International Bank Account Number)
. The "ISO 3166-1 alpha-2" country code can be specifed to narrow the pattern.
static static
if(mixed $actual, mixed $expected = true, string $operator = '==')
Adds if
rule. Checks the condition between the first argument and the second argument, the condition operator can also be specified as the third argument.
static static
ifEq(mixed $actual, mixed $expected)
Adds if.eq
rule. Checks the condition between the first argument and the second argument, the condition operator is "==".
static static
ifGt(mixed $actual, mixed $expected)
Adds if.gt
rule. Checks the condition between the first argument and the second argument, the condition operator is ">".
static static
ifGte(mixed $actual, mixed $expected)
Adds if.gte
rule. Checks the condition between the first argument and the second argument, the condition operator is ">=".
static static
ifId(mixed $actual, mixed $expected)
Adds if.id
rule. Checks the condition between the first argument and the second argument, the condition operator is "===".
static static
ifLt(mixed $actual, mixed $expected)
Adds if.lt
rule. Checks the condition between the first argument and the second argument, the condition operator is "<".
static static
ifLte(mixed $actual, mixed $expected)
Adds if.lte
rule. Checks the condition between the first argument and the second argument, the condition operator is "<=".
static static
ifNeq(mixed $actual, mixed $expected)
Adds if.neq
rule. Checks the condition between the first argument and the second argument, the condition operator is "!=".
static static
ifNid(mixed $actual, mixed $expected)
Adds if.nid
rule. Checks the condition between the first argument and the second argument, the condition operator is "!==".
static static
image() $dds `image` rule. Asserts that the input is an image file (jpg, svg $, or $ebp)
.
static static
imageDimensions(int $width, int $height, string $operator = '==')
Adds image.dimensions
rule. Asserts that the input is an image and its dimensions are less than, equal to, or greater than the given width and height in pixels.
static static
imageHeight(int $height)
Adds image.height
rule. Asserts that the input is an image and its height is equal to the given height in pixels.
static static
imageHeightGte(int $height)
Adds image.height.gte
rule. Asserts that the input is an image and its height is greater than or equal to the given height in pixels.
static static
imageHeightLte(int $height)
Adds image.height.lte
rule. Asserts that the input is an image and its height is less than or equal to the given height in pixels.
static static
imageRatio(string $ratio) Adds `image.ratio` rule. Asserts that the input is an image and its aspect ratio is equal to the given ratio (ratio must be specified like "16:9")
.
static static
imageWidth(int $width)
Adds image.width
rule. Asserts that the input is an image and its width is equal to the given width in pixels.
static static
imageWidthGte(int $width)
Adds image.width.gte
rule. Asserts that the input is an image and its width is greater than or equal to the given width in pixels.
static static
imageWidthLte(int $width)
Adds image.width.lte
rule. Asserts that the input is an image and its width is less than or equal to the given width in pixels.
static static
imei() $dds `imei` rule. Asserts that the input is a valid IMEI (International Mobile Station Equipment Identity Number)
.
static static
imeiSv() $dds `imei.sv` rule. Asserts that the input is a valid IMEI-SV (International Mobile Station Equipment Identity and Software Version Number)
.
static static
in(string|int|float|bool|null $values)
Adds in
rule. Asserts that the input is in the given values. Works with scalar types and null.
static static
int()
Adds int
rule. An alias for the integer
rule.
static static
integer()
Adds integer
rule. Asserts that the input is an integer.
static static
integerLike(int $min = PHP_INT_MIN, int $max = PHP_INT_MAX)
Adds integerLike
rule. Asserts that the input is a value that can be parsed as an integer within the specifed range.
static static
integerLikeAllowHex(int $min = PHP_INT_MIN, int $max = PHP_INT_MAX)
Adds integerLike.allowHex
rule. Asserts that the input is a value that can be parsed as an integer within the specifed range and can be in hexadecimal notation.
static static
integerLikeAllowOctal(int $min = PHP_INT_MIN, int $max = PHP_INT_MAX)
Adds integerLike.allowOctal
rule. Asserts that the input is a value that can be parsed as an integer within the specifed range and can be in octal notation.
static static
ip()
Adds ip
rule. Asserts that the input is an IP address.
static static
ipNotPrivate()
Adds ip.notPrivate
rule. Asserts that the input is an IP address not within private IPs range.
static static
ipNotReserved()
Adds ip.notReserved
rule. Asserts that the input is an IP address not within reserved IPs range.
static static
ipV4()
Adds ip.v4
rule. Asserts that the input is an IPv4 address.
static static
ipV6()
Adds ip.v6
rule. Asserts that the input is an IPv6 address.
static static
is(mixed $value)
Adds is
rule. An alias for the equals
rule.
static static
isbn(string|int|null $type = null) Adds `isbn` rule. Asserts that the input is a valid ISBN (International Standard Book Number). The type (10/13)
can be specifed to narrow the pattern.
static static
isin() $dds `isin` rule. Asserts that the input is a valid ISIN (International Securities Identification Number)
.
static static
issn() $dds `issn` rule. Asserts that the input is a valid ISSN (International Standard Serial Number)
.
static static
iterable()
Adds iterable
rule. Asserts that the input is an iterable.
static static
json()
Adds json
rule. Asserts that the input is a valid JSON.
static static
language(bool $long = false) Adds `language` rule. Asserts that the input is a valid language code (default: "ISO 639-1"; long: "ISO 639-2/T")
.
static static
length(int $count)
Adds length
rule. An alias for the count
rule.
static static
locale(bool $strict = false) Adds `locale` rule. Asserts that the input is a valid locale identifier (default: [ISO 639-1] or [ISO 639-1]_[ISO 3166-1 alpha-2], case-insensitive $, input $s canonicalized before checking (dashes to underscores, no $ots or charset)
; strict: [ISO 639-1] or [ISO 639-1]_[ISO 3166-1 alpha-2], case-sensitive without canonicalization.
static static
long()
Adds long
rule. An alias for the integer
rule.
static static
lower()
Adds lower
rule. Asserts that the input consists of lowercase characters only.
static static
luhn()
Adds luhn
rule. Asserts that the input passes the Luhn Algorithm check. This rule is mostly used in conjunction with other rules like credit card numbers and identifiers to further check the validity of the subject.
static static
mac()
Adds mac
rule. Asserts that the input is a MAC address.
Expression
macro(string $macro)
Writes a macro to the current expression string.
static static
matches(string $pattern)
Adds matches
rule. Asserts that the input matches the given pattern. Works with strings only.
static static
max(int|float $count) Adds `max` rule. Asserts that the input count is less than or equal to the given value. Works with all data types (null: 0; boolean: 0 or 1; float/integer: number value; string: characters count; array/countable: elements count; object: accessible properties count)
.
static static
meid() $dds `meid` rule. Asserts that the input is a valid MEID (Mobile Equipment Identifier)
.
static static
meta() $dds `meta` rule. Asserts that the input is a string containing only meta characters (special characters) (i.e. "@, ..." $)
.
static static
min(int|float $count) Adds `min` rule. Asserts that the input count is greater than or equal to the given value. Works with all data types (null: 0; boolean: 0 or 1; float/integer: number value; string: characters count; array/countable: elements count; object: accessible properties count)
.
static static
minmax(int|float $min, int|float $max)
Adds minmax
rule. An alias for the between
rule.
static Validation
new()
Creates a new Validation instance that is bound to the default Validator.
static static
nino() $dds `nino` rule. Asserts that the input is a valid NINO (UK National Insurance Number)
.
Expression
normal()
Makes the expression normal (executes all checks). The is the default behavior.
NOTE: Use this to remove an already added behavior.
Expression
not()
Adds NOT operator (tilde: ~
). Negates the next rule/group.
static static
null()
Adds null
rule. Asserts that the input is null.
static static
numberIsEven()
Adds number.isEven
rule. Asserts that the input is an even number.
static static
numberIsFinite()
Adds number.isFinite
rule. Asserts that the input is a finite number.
static static
numberIsInfinite()
Adds number.isInfinite
rule. Asserts that the input is an infinite number.
static static
numberIsMultipleOf(float $number)
Adds number.isMultipleOf
rule. Asserts that the input is a multiple of the given number.
static static
numberIsNan()
Adds number.isNan
rule. Asserts that the input is a not a number.
static static
numberIsNegative()
Adds number.isNegative
rule. Asserts that the input is a negative number.
static static
numberIsOdd()
Adds number.isOdd
rule. Asserts that the input is an odd number.
static static
numberIsPositive()
Adds number.isPositive
rule. Asserts that the input is a positive number.
static static
numeric()
Adds numeric
rule. Asserts that the input is numeric.
static static
obj()
Adds obj
rule. An alias for the object
rule.
static static
object()
Adds object
rule. Asserts that the input is an object.
static static
objectHasMethod(string $method)
Adds object.hasMethod
rule. Asserts that the input has the given method.
static static
objectHasProperty(string $property)
Adds object.hasProperty
rule. Asserts that the input has the given property.
static static
objectIsInstanceOf(string $classFQN)
Adds object.isInstanceOf
rule. Asserts that the input is an instance of the given class.
static static
objectIsStringable() $dds `object.isStringable` rule. Asserts that the input implements __toString()
method.
static static
objectIsSubclassOf(string $classFQN)
Adds object.isSubclassOf
rule. Asserts that the input is a subclass of the given class.
Expression
open()
Adds OPEN operator (opening parenthesis: (
). Starts a new group.
Expression
optimistic()
Makes the expression optimistic (stop checking after first success).
NOTE: This has effect only if the expression is not already PESSIMISTIC
.
NOTE: Be careful when using OPTIMISTIC
with AND
or XOR
.
static static
optional()
Adds optional
rule. An alias for the allowed
rule.
Expression
or()
Adds OR operator (pipe: |
). Ors the next rule/group.
static static
password() $dds `password` rule. Asserts that the input is a valid password (minimum 8 characters, consists $f at least one small letter and one capital letter, at $east one number, at $east one special character, and $ptionally a space)
.
static static
pattern(string $pattern)
Adds pattern
rule. An alias for the matches
rule.
Expression
pessimistic()
Makes the expression pessimistic (stop checking after first failure).
NOTE: This has effect only if the expression is not already PESSIMISTIC
.
NOTE: Be careful when using PESSIMISTIC
with OR
or XOR
.
static static
phone() $dds `phone` rule. Asserts that the input is a valid phone number (supports: North America, Europe $nd most Asian and Middle East countries)
.
static static
phpKeyword()
Adds php.keyword
rule. Asserts that the input is a PHP language Keyword.
static static
phpReserved()
Adds php.reserved
rule. Asserts that the input is a PHP language reserved word.
static static
phpReservedExtra()
Adds php.reserved.extra
rule. Asserts that the input is a PHP language reserved word including soft reserved words.
static static
present()
Adds present
rule. An alias for the required
rule.
static static
print()
Adds print
rule. Asserts that the input consists of printable characters only.
static static
punct()
Adds punct
rule. Asserts that the input consists of punctuation characters only.
static static
range(int|float $min, int|float $max)
Adds range
rule. An alias for the between
rule.
static static
real()
Adds real
rule. An alias for the float
rule.
static static
regex()
Adds regex
rule. Asserts that the input is a valid regular expression.
Aliases:
static static
regexp(string $pattern)
Adds regexp
rule. Asserts that the input matches a Perl-compatible regular expression.
static static
required() $dds `required` rule. Asserts that the input is required (is not blank, i.e. $ot a empty string or null)
.
static static
resource()
Adds resource
rule. Asserts that the input is a resource.
static static
roman()
Adds roman
rule. Asserts that the input is a valid roman number.
Expression
rule(string $rule)
Writes a rule to the current expression string.
static static
same(mixed $value)
Adds same
rule. An alias for the equals
rule.
static static
scalar()
Adds scalar
rule. Asserts that the input is a scalar.
static static
serialized()
Adds serialized
rule. Asserts that the input is a valid PHP serialized data.
static static
sin() $dds `sin` rule. Asserts that the input is a valid SIN (CA Social Insurance Number)
.
static static
size(int $size)
Adds size
rule. An alias for the count
rule.
static static
slug()
Adds slug
rule. Asserts that the input is a valid slug.
static static
space()
Adds space
rule. Asserts that the input consists of whitespace characters only.
static static
spaceless()
Adds spaceless
rule. Asserts that the input is a string containing no whitespace characters.
static static
ssn() $dds `ssn` rule. Asserts that the input is a valid SSN (Social Security Number)
.
static static
str()
Adds str
rule. An alias for the string
rule.
static static
stream()
Adds stream
rule. An alias for the resource
rule.
static static
string()
Adds string
rule. Asserts that the input is a string.
static static
stringCharset(string|array $charset) Adds `string.charset` rule. Asserts that the input is encoded in one of the given charsets (aliases included)
. The check is done in a case-sensitive manner.
static static
stringContains(string $substring, bool $strict = false) Adds `string.contains` rule. Asserts that the input contains the given substring. A second boolean argument can be specified to enable strict mode (case-sensitive)
.
static static
stringEndsWith(string $substring, bool $strict = false) Adds `string.endsWith` rule. Asserts that the input ends with the given substring. A second boolean argument can be specified to enable strict mode (case-sensitive)
.
static static
stringLength(int $length)
Adds string.length
rule. Asserts that the input is a string that is exactly the given length.
static static
stringStartsWith(string $substring, bool $strict = false) Adds `string.startsWith` rule. Asserts that the input starts with the given substring. A second boolean argument can be specified to enable strict mode (case-sensitive)
.
static static
stringWordsCount(int $count)
Adds string.wordsCount
rule. Asserts that the input is a string containing exactly the given count of words.
static static
text()
Adds text
rule. Asserts that the input is a string containing letters and punctuation from any language.
static static
timestamp()
Adds timestamp
rule. Asserts that the input looks like a human timestamp, 24 or 12 hours format with or without seconds.
static static
timestamp12()
Adds timestamp.12
rule. Asserts that the input looks like a human timestamp, 12 hours format with or without seconds and optional AM/PM..
static static
timestampHm()
Adds timestamp.hm
rule. Asserts that the input looks like a human timestamp, 24 or 12 hours format without seconds.
static static
timestampHms()
Adds timestamp.hms
rule. Asserts that the input looks like a human timestamp, 24 or 12 hours format with seconds.
static static
timestampMs()
Adds timestamp.ms
rule. Asserts that the input looks like a human timestamp, containing minutes and seconds only.
static static
timezone(bool $strict = false) Adds `timezone` rule. Asserts that the input is a valid timezone identifier (default: case-insensitive; strict: case-sensitive)
.
static static
type(string|array $type)
Adds type
rule. Asserts that the input is one of the given types.
static static
typeDebug(string $type) Adds `type.debug` rule. Asserts that the input is of the given type using get_debug_type()
.
static static
upper()
Adds upper
rule. Asserts that the input consists of uppercase characters only.
static static
url()
Adds url
rule. Asserts that the input is a URL.
static static
urlWithPath()
Adds url.withPath
rule. Asserts that the input is a URL that contains a path.
static static
urlWithQuery()
Adds url.withQuery
rule. Asserts that the input is a URL that contains a query.
static static
username() $dds `username` rule. Asserts that the input is a valid username (between 4-32 characters, consists $f letters in any case, optionally $umbers, optionally $ne of the following characters "-_." (not consecutive), and $ust always start with a letter and end with a letter or number)
.
static static
uuid(string|int|null $version = null) Adds `uuid` rule. Asserts that the input is a valid UUID. The version (v1/v2/v3/v4/v5)
can be specifed to narrow the pattern.
static string
variable(string $key)
Returns a the passed key as a valid back-reference injectable.
static static
version()
Adds version
rule. Asserts that the input is a valid semantic version number.
static static
vin() $dds `vin` rule. Asserts that the input is a valid VIN (Vehicle Identification Number)
.
static static
words()
Adds words
rule. Asserts that the input is a string containing only words and spaces without any other character.
Expression
write(string $string)
Writes the passed string to the current expression string buffer.
Note that the necessary operators will be added automatically.
static static
xdigit()
Adds xdigit
rule. Asserts that the input represent hexadecimal digits.
static static
xml()
Adds xml
rule. Asserts that the input is a valid XML.
Expression
xor()
Adds XOR operator (caret: ^
). Xors the next rule/group.