Skip to content

Latest commit

 

History

History
535 lines (345 loc) · 12.5 KB

File metadata and controls

535 lines (345 loc) · 12.5 KB

Validation Rules Reference

Complete reference of all 30 built-in validation rules.

Table of Contents


Comparison

notIn - Validates that a value does not exist in a forbidden list or as an obj...

Description:

Validates that a value does not exist in a forbidden list or as an object property

Parameters:

NameTypeRequiredDescription
forbiddenobject|arrayArray or object of forbidden values
Example: ["admin","root"]

Usage:

$verifier->field("test")->notIn(["admin", "root"])
in - Validates that a value exists in an allowed list or as an object prope...

Description:

Validates that a value exists in an allowed list or as an object property

Parameters:

NameTypeRequiredDescription
allowedobject|arrayArray or object of allowed values
Example: ["active","pending"]

Usage:

$verifier->field("test")->in(["active", "pending"])

Core

required - Validates that a field is not empty. Objects are cast to arrays to che...

Description:

Validates that a field is not empty. Objects are cast to arrays to check emptiness.

Usage:

$verifier->field("test")->required

Date

date - Validates that a value is a valid date in the specified format. Perfor...

Description:

Validates that a value is a valid date in the specified format. Performs strict validation

Parameters:

NameTypeRequiredDescription
formatstringDate format
Example: 'Y-m-d'
Default: 'Y-m-d'

Usage:

$verifier->field("test")->date("Y-m-d")

File

fileMime - Validates that a file has an allowed MIME type

Parameters:

NameTypeRequiredDescription
mimearray|stringAllowed MIME type(s)
Example: 'image/jpeg'

Usage:

$verifier->field("test")->fileMime("image/jpeg")
fileExists - Validates that a file exists at the given path

Usage:

$verifier->field("test")->fileExists

Numeric

between - Validates that a value is between two bounds. Supports numeric values ...

Description:

Validates that a value is between two bounds. Supports numeric values and DateTime objects

Parameters:

NameTypeRequiredDescription
minDateTime|string|int|floatMinimum value (inclusive)
Example: 18
maxDateTime|string|int|floatMaximum value (inclusive)
Example: 65

Usage:

$verifier->field("test")->between(18, 65)
greaterThan - Validates that a value is greater than a specified limit

Parameters:

NameTypeRequiredDescription
minmixedValue must be greater than this
Example: 18

Usage:

$verifier->field("test")->greaterThan(18)
lowerThan - Validates that a value is less than a specified limit

Parameters:

NameTypeRequiredDescription
maxmixedValue must be less than this
Example: 65

Usage:

$verifier->field("test")->lowerThan(65)

String

alphanumeric - Validates that a value contains only alphanumeric characters

Usage:

$verifier->field("test")->alphanumeric
maxLength - Validates that a string does not exceed maximum length

Parameters:

NameTypeRequiredDescription
maxintMaximum length allowed
Example: 20

Usage:

$verifier->field("test")->maxLength(20)
disposableEmail - Validates that an email is not from a disposable domain, can be overri...

Description:

Validates that an email is not from a disposable domain, can be overriden ["@yourDisposableDomain", ...]

Parameters:

NameTypeRequiredDescription
disposablesarrayArray of disposable domain patterns
Example: []
Default: []

Usage:

$verifier->field("email")->disposableEmail
$verifier->field("email")->disposableEmail(["@yourDisposableDomain", ...])
disposableUrlDomain - Validates that a URL is not from a disposable/temporary domain (URL sh...

Description:

Validates that a URL is not from a disposable/temporary domain (URL shorteners, free hosting, etc.)

Parameters:

NameTypeRequiredDescription
disposablesarrayArray of disposable domain patterns
Example: []
Default: []

Usage:

$verifier->field("website")->disposableUrlDomain
$verifier->field("website")->disposableUrlDomain(["bit.ly", "tinyurl.com"])
url - Validates that a value is a valid URL with configurable schemes and TL...

Description:

Validates that a value is a valid URL with configurable schemes and TLD requirement

Parameters:

NameTypeRequiredDescription
schemesarrayAllowed URL schemes
Example: ["http","https"]
Default: ["http","https"]
requireTldboolRequire a top-level domain (.com|.org|.net|...)
Example: true
Default: true

Usage:

$verifier->field("website")->url
$verifier->field("api")->url(["http", "https", "ws", "wss"])
$verifier->field("intranet")->url(["http"], requireTld: false)
containsNumber - Validates that a string contains at least one digit

Usage:

$verifier->field("test")->containsNumber
notAlphanumeric - Validates that a value contains non-alphanumeric characters

Usage:

$verifier->field("test")->notAlphanumeric
minLength - Validates that a string has a minimum length

Parameters:

NameTypeRequiredDescription
minintMinimum length required
Example: 8

Usage:

$verifier->field("test")->minLength(8)
containsUpper - Validates that a string contains at least one uppercase letter

Usage:

$verifier->field("test")->containsUpper
email - Validates that a value is a valid email address

Usage:

$verifier->field("test")->email
regex - Validates that a value matches a regular expression pattern. Warnings ...

Description:

Validates that a value matches a regular expression pattern. Warnings are suppressed

Parameters:

NameTypeRequiredDescription
patternstringRegular expression pattern
Example: '/^[A-Z]+$/'

Usage:

$verifier->field("test")->regex("/^[A-Z]+$/")
ipAddress - Validates that a value is a valid IP address (IPv4 or IPv6)

Usage:

$verifier->field("test")->ipAddress
containsLower - Validates that a string contains at least one lowercase letter

Usage:

$verifier->field("test")->containsLower
containsSpecialCharacter - Validates that a string contains at least one special character

Usage:

$verifier->field("test")->containsSpecialCharacter

Type

string - Validates that a value is a string

Usage:

$verifier->field("test")->string
int - Validates that a value is an integer. In strict mode (default), only t...

Description:

Validates that a value is an integer. In strict mode (default), only true integers are accepted

Parameters:

NameTypeRequiredDescription
strictboolStrict mode: true for integers only
Example: true
Default: true

Usage:

$verifier->field("test")->int(true)
array - Validates that a value is an array

Usage:

$verifier->field("test")->array
object - Validates that a value is an object

Usage:

$verifier->field("test")->object
boolean - Validates that a value is a boolean. In strict mode (default), only tr...

Description:

Validates that a value is a boolean. In strict mode (default), only true/false are accepted

Parameters:

NameTypeRequiredDescription
strictboolStrict mode: true for booleans only
Example: true
Default: true

Usage:

$verifier->field("test")->boolean(true)
json - Validates that a string is valid JSON

Usage:

$verifier->field("test")->json
numeric - Validates that a value is numeric

Usage:

$verifier->field("test")->numeric

See Also