Rules
extends BaseRules
in package
uses
Validator, FilesValidator
Class Rules.
Table of Contents
Properties
- $rules : array<int, string>
Methods
- __construct() : mixed
- __get() : mixed
- __toString() : string
- alpha() : static
- Validates alphabetic characters.
- alphaNumber() : static
- Validates a number or alphabetic characters.
- array() : static
- Validates array.
- base64() : static
- Validates a base64 string.
- between() : static
- Validate field between min and max values.
- blank() : static
- If the field has a blank string, the validation passes.
- bool() : static
- Validates boolean.
- create() : static
- datetime() : static
- Validates a datetime format.
- dim() : static
- Validates image dimensions.
- email() : static
- Validates a email.
- empty() : static
- If the field has an empty value, the validation passes.
- equals() : static
- Validate field has value equals other field.
- ext() : static
- Validates file accepted extensions.
- float() : static
- Validates float.
- greater() : static
- Validates is greater than.
- greaterOrEqual() : static
- Validates is greater than or equal to.
- hex() : static
- Validates a hexadecimal string.
- hexColor() : static
- Validates a hexadecimal color.
- image() : static
- Validates file is an image.
- in() : static
- Validate field is in list.
- int() : static
- Validates integer.
- ip() : static
- Validates an IP.
- isset() : static
- Validates field is set.
- json() : static
- Validates a JSON string.
- latin() : static
- Validates a latin text.
- length() : static
- Validates exact length.
- less() : static
- Validates is less than.
- lessOrEqual() : static
- Validates is less than or equal to.
- maxDim() : static
- Validates image max dimensions.
- maxLength() : static
- Validates max length.
- maxSize() : static
- Validates file size.
- md5() : static
- Validates a md5 hash.
- mimes() : static
- Validates file accepted MIME types.
- minDim() : static
- Validates image min dimensions.
- minLength() : static
- Validates min length.
- notBetween() : static
- Validate field not between min and max values.
- notEquals() : static
- Validate field has not value equals other field.
- notIn() : static
- Validate field is not in list.
- notRegex() : static
- Validates a Regex no matching pattern.
- null() : static
- If the field value is null, the validation passes.
- number() : static
- Validates a number.
- object() : static
- Validates object.
- optional() : static
- Set field as optional.
- regex() : static
- Validates a Regex pattern.
- required() : static
- Validates required value.
- slug() : static
- Validates slug.
- specialChar() : static
- Validates special characters.
- string() : static
- Validates string.
- timezone() : static
- Validates a timezone.
- uploaded() : static
- Validates file is uploaded.
- url() : static
- Validates an URL.
- uuid() : static
- Validates a UUID.
- esc() : string
- implode() : string
Properties
$rules read-only
public
array<int, string>
$rules
Methods
__construct()
public
final __construct() : mixed
Tags
__get()
public
__get(string $property) : mixed
Parameters
- $property : string
__toString()
public
__toString() : string
Return values
stringalpha()
Validates alphabetic characters.
public
alpha() : static
Return values
staticalphaNumber()
Validates a number or alphabetic characters.
public
alphaNumber() : static
Return values
staticarray()
Validates array.
public
array() : static
Tags
Return values
staticbase64()
Validates a base64 string.
public
base64() : static
Return values
staticbetween()
Validate field between min and max values.
public
between(int|string $min, int|string $max) : static
Parameters
- $min : int|string
- $max : int|string
Return values
staticblank()
If the field has a blank string, the validation passes.
public
blank() : static
Tags
Return values
staticbool()
Validates boolean.
public
bool() : static
Tags
Return values
staticcreate()
public
static create() : static
Return values
staticdatetime()
Validates a datetime format.
public
datetime([string $format = 'Y-m-d H:i:s' ]) : static
Parameters
- $format : string = 'Y-m-d H:i:s'
Return values
staticdim()
Validates image dimensions.
public
dim(int $width, int $height) : static
Parameters
- $width : int
- $height : int
Return values
staticemail()
Validates a email.
public
email() : static
Return values
staticempty()
If the field has an empty value, the validation passes.
public
empty() : static
Tags
Return values
staticequals()
Validate field has value equals other field.
public
equals(string $equalsField) : static
Parameters
- $equalsField : string
Return values
staticext()
Validates file accepted extensions.
public
ext(string ...$allowedExtensions) : static
NOTE: For greater security use the FilesValidator::mimes() method to filter the file type.
Parameters
- $allowedExtensions : string
Return values
staticfloat()
Validates float.
public
float() : static
Tags
Return values
staticgreater()
Validates is greater than.
public
greater(int|string $greaterThan) : static
Parameters
- $greaterThan : int|string
Return values
staticgreaterOrEqual()
Validates is greater than or equal to.
public
greaterOrEqual(int|string $greaterThanOrEqualTo) : static
Parameters
- $greaterThanOrEqualTo : int|string
Return values
statichex()
Validates a hexadecimal string.
public
hex() : static
Return values
statichexColor()
Validates a hexadecimal color.
public
hexColor() : static
Return values
staticimage()
Validates file is an image.
public
image() : static
Return values
staticin()
Validate field is in list.
public
in(string $in, string ...$others) : static
Parameters
- $in : string
- $others : string
Return values
staticint()
Validates integer.
public
int() : static
Tags
Return values
staticip()
Validates an IP.
public
ip([int $version = 0 ]) : static
Parameters
- $version : int = 0
-
4, 6 or 0 to both
Return values
staticisset()
Validates field is set.
public
isset() : static
Return values
staticjson()
Validates a JSON string.
public
json() : static
Return values
staticlatin()
Validates a latin text.
public
latin() : static
Return values
staticlength()
Validates exact length.
public
length(int $length) : static
Parameters
- $length : int
Return values
staticless()
Validates is less than.
public
less(int|string $lessThan) : static
Parameters
- $lessThan : int|string
Return values
staticlessOrEqual()
Validates is less than or equal to.
public
lessOrEqual(int|string $lessThanOrEqualTo) : static
Parameters
- $lessThanOrEqualTo : int|string
Return values
staticmaxDim()
Validates image max dimensions.
public
maxDim(int $width, int $height) : static
Parameters
- $width : int
- $height : int
Return values
staticmaxLength()
Validates max length.
public
maxLength(int $maxLength) : static
Parameters
- $maxLength : int
Return values
staticmaxSize()
Validates file size.
public
maxSize(int $kilobytes) : static
Parameters
- $kilobytes : int
Return values
staticmd5()
Validates a md5 hash.
public
md5() : static
Return values
staticmimes()
Validates file accepted MIME types.
public
mimes(string ...$allowedTypes) : static
Parameters
- $allowedTypes : string
Return values
staticminDim()
Validates image min dimensions.
public
minDim(int $width, int $height) : static
Parameters
- $width : int
- $height : int
Return values
staticminLength()
Validates min length.
public
minLength(int $minLength) : static
Parameters
- $minLength : int
Return values
staticnotBetween()
Validate field not between min and max values.
public
notBetween(int|string $min, int|string $max) : static
Parameters
- $min : int|string
- $max : int|string
Return values
staticnotEquals()
Validate field has not value equals other field.
public
notEquals(string $diffField) : static
Parameters
- $diffField : string
Return values
staticnotIn()
Validate field is not in list.
public
notIn(string $notIn, string ...$others) : static
Parameters
- $notIn : string
- $others : string
Return values
staticnotRegex()
Validates a Regex no matching pattern.
public
notRegex(string $pattern) : static
Parameters
- $pattern : string
Return values
staticnull()
If the field value is null, the validation passes.
public
null() : static
Tags
Return values
staticnumber()
Validates a number.
public
number() : static
Return values
staticobject()
Validates object.
public
object() : static
Tags
Return values
staticoptional()
Set field as optional.
public
optional() : static
If field is undefined, validation passes.
Return values
staticregex()
Validates a Regex pattern.
public
regex(string $pattern) : static
Parameters
- $pattern : string
Return values
staticrequired()
Validates required value.
public
required() : static
Return values
staticslug()
Validates slug.
public
slug() : static
Tags
Return values
staticspecialChar()
Validates special characters.
public
specialChar([int $quantity = 1 ][, string $characters = '!"#$%&\'()*+,-./:;=<>?@[\]^_`{|}~' ]) : static
Parameters
- $quantity : int = 1
- $characters : string = '!"#$%&\'()*+,-./:;=<>?@[\]^_`{|}~'
Tags
Return values
staticstring()
Validates string.
public
string() : static
Tags
Return values
statictimezone()
Validates a timezone.
public
timezone() : static
Return values
staticuploaded()
Validates file is uploaded.
public
uploaded() : static
Return values
staticurl()
Validates an URL.
public
url() : static
Return values
staticuuid()
Validates a UUID.
public
uuid() : static
Return values
staticesc()
protected
esc(string $value) : string
Parameters
- $value : string
Return values
stringimplode()
protected
implode(array<string|int, scalar> $values) : string
Parameters
- $values : array<string|int, scalar>