Rules
extends BaseRules
in package
Uses
Validator, FilesValidator
Class Rules.
Table of Contents
- $rules : array<int, string>
- $rules : array<string|int, mixed>
- __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
$rules
protected
array<string|int, mixed>
$rules
= []
Methods
__construct()
public
final __construct() : mixed
Tags
Return values
mixed —__get()
public
__get(string $property) : mixed
Parameters
- $property : string
Return values
mixed —__toString()
public
__toString() : string
Return values
string —alpha()
Validates alphabetic characters.
public
alpha() : static
Return values
static —alphaNumber()
Validates a number or alphabetic characters.
public
alphaNumber() : static
Return values
static —array()
Validates array.
public
array() : static
Tags
Return values
static —base64()
Validates a base64 string.
public
base64() : static
Return values
static —between()
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
static —blank()
If the field has a blank string, the validation passes.
public
blank() : static
Tags
Return values
static —bool()
Validates boolean.
public
bool() : static
Tags
Return values
static —create()
public
static create() : static
Return values
static —datetime()
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
static —dim()
Validates image dimensions.
public
dim(int $width, int $height) : static
Parameters
- $width : int
- $height : int
Return values
static —email()
Validates a email.
public
email() : static
Return values
static —empty()
If the field has an empty value, the validation passes.
public
empty() : static
Tags
Return values
static —equals()
Validate field has value equals other field.
public
equals(string $equalsField) : static
Parameters
- $equalsField : string
Return values
static —ext()
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
static —float()
Validates float.
public
float() : static
Tags
Return values
static —greater()
Validates is greater than.
public
greater(int|string $greaterThan) : static
Parameters
- $greaterThan : int|string
Return values
static —greaterOrEqual()
Validates is greater than or equal to.
public
greaterOrEqual(int|string $greaterThanOrEqualTo) : static
Parameters
- $greaterThanOrEqualTo : int|string
Return values
static —hex()
Validates a hexadecimal string.
public
hex() : static
Return values
static —hexColor()
Validates a hexadecimal color.
public
hexColor() : static
Return values
static —image()
Validates file is an image.
public
image() : static
Return values
static —in()
Validate field is in list.
public
in(string $in, string ...$others) : static
Parameters
- $in : string
- $others : string
Return values
static —int()
Validates integer.
public
int() : static
Tags
Return values
static —ip()
Validates an IP.
public
ip(int $version) : static
Parameters
- $version : int
-
4, 6 or 0 to both
Return values
static —isset()
Validates field is set.
public
isset() : static
Return values
static —json()
Validates a JSON string.
public
json() : static
Return values
static —latin()
Validates a latin text.
public
latin() : static
Return values
static —length()
Validates exact length.
public
length(int $length) : static
Parameters
- $length : int
Return values
static —less()
Validates is less than.
public
less(int|string $lessThan) : static
Parameters
- $lessThan : int|string
Return values
static —lessOrEqual()
Validates is less than or equal to.
public
lessOrEqual(int|string $lessThanOrEqualTo) : static
Parameters
- $lessThanOrEqualTo : int|string
Return values
static —maxDim()
Validates image max dimensions.
public
maxDim(int $width, int $height) : static
Parameters
- $width : int
- $height : int
Return values
static —maxLength()
Validates max length.
public
maxLength(int $maxLength) : static
Parameters
- $maxLength : int
Return values
static —maxSize()
Validates file size.
public
maxSize(int $kilobytes) : static
Parameters
- $kilobytes : int
Return values
static —md5()
Validates a md5 hash.
public
md5() : static
Return values
static —mimes()
Validates file accepted MIME types.
public
mimes(string ...$allowedTypes) : static
Parameters
- $allowedTypes : string
Return values
static —minDim()
Validates image min dimensions.
public
minDim(int $width, int $height) : static
Parameters
- $width : int
- $height : int
Return values
static —minLength()
Validates min length.
public
minLength(int $minLength) : static
Parameters
- $minLength : int
Return values
static —notBetween()
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
static —notEquals()
Validate field has not value equals other field.
public
notEquals(string $diffField) : static
Parameters
- $diffField : string
Return values
static —notIn()
Validate field is not in list.
public
notIn(string $notIn, string ...$others) : static
Parameters
- $notIn : string
- $others : string
Return values
static —notRegex()
Validates a Regex no matching pattern.
public
notRegex(string $pattern) : static
Parameters
- $pattern : string
Return values
static —null()
If the field value is null, the validation passes.
public
null() : static
Tags
Return values
static —number()
Validates a number.
public
number() : static
Return values
static —object()
Validates object.
public
object() : static
Tags
Return values
static —optional()
Set field as optional.
public
optional() : static
If field is undefined, validation passes.
Return values
static —regex()
Validates a Regex pattern.
public
regex(string $pattern) : static
Parameters
- $pattern : string
Return values
static —required()
Validates required value.
public
required() : static
Return values
static —slug()
Validates slug.
public
slug() : static
Tags
Return values
static —specialChar()
Validates special characters.
public
specialChar([int $quantity = 1 ][, string $characters = '!"#$%&'()*+,-./:;=<>?@[\]^_`{|}~' ]) : static
Parameters
- $quantity : int = 1
- $characters : string = '!"#$%&'()*+,-./:;=<>?@[\]^_`{|}~'
Tags
Return values
static —string()
Validates string.
public
string() : static
Tags
Return values
static —timezone()
Validates a timezone.
public
timezone() : static
Return values
static —uploaded()
Validates file is uploaded.
public
uploaded() : static
Return values
static —url()
Validates an URL.
public
url() : static
Return values
static —uuid()
Validates a UUID.
public
uuid() : static
Return values
static —esc()
protected
esc(string $value) : string
Parameters
- $value : string
Return values
string —implode()
protected
implode(array<string|int, scalar> $values) : string
Parameters
- $values : array<string|int, scalar>