trait ValidatesAttributes

Methods

bool
validateAccepted(string $attribute, mixed $value)

Validate that an attribute was "accepted".

bool
validateAcceptedIf(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute was "accepted" when another attribute has a given value.

bool
validateDeclined(string $attribute, mixed $value)

Validate that an attribute was "declined".

bool
validateDeclinedIf(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute was "declined" when another attribute has a given value.

bool
validateActiveUrl(string $attribute, mixed $value)

Validate that an attribute is an active URL.

array|false
getDnsRecords(string $hostname, int $type)

Get the DNS records for the given hostname.

bool
validateAscii(string $attribute, mixed $value)

Validate that an attribute is 7 bit ASCII.

bool
validateBase64(string $attribute, mixed $value)

Validate that an attribute is a valid Base64 string.

bool
validateBail()

"Break" on first validation fail.

bool
validateBefore(string $attribute, mixed $value, mixed $parameters)

Validate the date is before a given date.

bool
validateBeforeOrEqual(string $attribute, mixed $value, mixed $parameters)

Validate the date is before or equal a given date.

bool
validateAfter(string $attribute, mixed $value, mixed $parameters)

Validate the date is after a given date.

bool
validateAfterOrEqual(string $attribute, mixed $value, mixed $parameters)

Validate the date is equal or after a given date.

bool
compareDates(string $attribute, mixed $value, array $parameters, string $operator)

Compare a given date against another using an operator.

string|null
getDateFormat(string $attribute)

Get the date format for an attribute if it has one.

int|null
getDateTimestamp(mixed $value)

Get the date timestamp.

bool
checkDateTimeOrder(string $format, mixed $value, mixed $argument, string $operator)

Compare a date value with a literal or referenced field using the given format.

getDateTimeWithOptionalFormat(string $format, mixed $value)

Get a DateTime instance from a supported value using the given format.

getDateTime(DateTimeInterface|float|int|string $value)

Get a DateTime instance from a string with no format.

bool
validateAlpha(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute contains only alphabetic characters.

bool
validateAlphaDash(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute contains only alpha-numeric characters, dashes, and underscores.

bool
validateAlphaNum(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute contains only alpha-numeric characters.

bool
validateArray(string $attribute, mixed $value, array $parameters = [])

Validate that an attribute is an array.

array
acceptedArrayKeys(array $parameters)

Get the accepted literal and encoded array keys.

bool
validateArrayKeys(string $attribute, mixed $value, array $parameters)

Validate that an array does not contain any keys other than the given keys.

bool
validateList(string $attribute, mixed $value)

Validate that an attribute is a list.

bool
validateRequiredArrayKeys(string $attribute, mixed $value, array $parameters)

Validate that an array has all of the given keys.

bool
validateBetween(string $attribute, mixed $value, array $parameters)

Validate the size of an attribute is between a set of values.

bool
validateBoolean(string $attribute, mixed $value, array $parameters)

Validate that an attribute is a boolean.

bool
validateConfirmed(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute has a matching confirmation.

bool
validateContains(string $attribute, mixed $value, mixed $parameters)

Validate an attribute contains a list of values.

bool
validateDoesntContain(string $attribute, mixed $value, mixed $parameters)

Validate an attribute does not contain a list of values.

bool
validateCurrentPassword(string $attribute, mixed $value, mixed $parameters)

Validate that the password of the currently authenticated user matches the given value.

bool
validateDate(string $attribute, mixed $value)

Validate that an attribute is a valid date.

bool
isValidDate(mixed $value)

Determine if a value is a valid date.

bool
validateDateFormat(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute matches a date format.

bool
matchesDateFormat(mixed $value, string $format)

Determine if a value matches a specific date format.

bool
validateDateEquals(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute is equal to another date.

bool
validateDecimal(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute has a given number of decimal places.

bool
validateDifferent(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute is different from another attribute.

bool
validateDigits(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute has a given number of digits.

bool
validateDigitsBetween(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute is between a given number of digits.

bool
validateDimensions(string $attribute, mixed $value, mixed $parameters)

Validate the dimensions of an image matches the given values.

bool
failsBasicDimensionChecks(array $parameters, int $width, int $height)

Test if the given width and height fail any conditions.

bool
failsRatioCheck(array $parameters, int $width, int $height)

Determine if the given parameters fail a dimension ratio check.

bool
validateDistinct(string $attribute, mixed $value, mixed $parameters)

Validate an attribute is unique among other values.

string|null
getDistinctValueKey(mixed $value)

Identify values whose strict equality can be counted without comparing every sibling.

array
getDistinctValues(string $attribute)

Get the values to distinct between.

array
extractDistinctValues(string $attribute)

Extract the distinct values from the data.

bool
validateEmail(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute is a valid e-mail address.

bool
isValidEmail(string $value)

Determine if a value is a valid email address using basic RFC validation.

bool
validateEncoding(string $attribute, mixed $value, array $parameters)

Validate the encoding of an attribute.

bool
validateExists(string $attribute, mixed $value, mixed $parameters)

Validate the existence of an attribute value in a database table.

int
getExistCount(mixed $connection, string $table, string $column, mixed $value, array $parameters)

Get the number of records that exist in storage.

bool
validateUnique(string $attribute, mixed $value, mixed $parameters)

Validate the uniqueness of an attribute value on a given database table.

array
getUniqueIds(string|null $idColumn, array $parameters)

Get the excluded ID column and value for the unique rule.

int|string|null
prepareUniqueId(mixed $id)

Prepare the given ID for querying.

array
getUniqueExtra(array $parameters)

Get the extra conditions for a unique rule.

array
parseTable(string $table)

Parse the connection / table for the unique / exists rules.

bool|string
getQueryColumn(array $parameters, string $attribute)

Get the column name for an exists / unique query.

string
guessColumnForQuery(string $attribute)

Guess the database column from the given attribute name.

array
getExtraConditions(array $segments)

Get the extra conditions for a unique / exists rule.

bool
validateExtensions(string $attribute, mixed $value, array $parameters)

Validate the extension of a file upload attribute is in a set of defined extensions.

bool
validateFile(string $attribute, mixed $value)

Validate the given value is a valid file.

bool
validateFilled(string $attribute, mixed $value)

Validate the given attribute is filled if it is present.

bool
validateGt(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute is greater than another attribute.

bool
validateLt(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute is less than another attribute.

bool
validateGte(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute is greater than or equal another attribute.

bool
validateLte(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute is less than or equal another attribute.

bool
validateLowercase(string $attribute, mixed $value)

Validate that an attribute is lowercase.

bool
validateUppercase(string $attribute, mixed $value)

Validate that an attribute is uppercase.

bool
validateHexColor(string $attribute, mixed $value)

Validate that an attribute is a valid HEX color.

bool
validateImage(string $attribute, mixed $value, array $parameters = [])

Validate the MIME type of a file is an image MIME type.

bool
validateIn(string $attribute, mixed $value, mixed $parameters)

Validate an attribute is contained within a list of values.

bool
validateInArray(string $attribute, mixed $value, mixed $parameters)

Validate that the values of an attribute are in another attribute.

bool
validateInArrayKeys(string $attribute, mixed $value, array $parameters)

Validate that an array contains at least one of the given keys.

bool
validateInteger(string $attribute, mixed $value, array $parameters = [])

Validate that an attribute is an integer.

bool
validateIp(string $attribute, mixed $value)

Validate that an attribute is a valid IP.

bool
validateIpv4(string $attribute, mixed $value)

Validate that an attribute is a valid IPv4.

bool
validateIpv6(string $attribute, mixed $value)

Validate that an attribute is a valid IPv6.

bool
isValidIp(string $value)

Determine if a value is a valid IP address (any version).

bool
isValidIpv4(string $value)

Determine if a value is a valid IPv4 address.

bool
isValidIpv6(string $value)

Determine if a value is a valid IPv6 address.

bool
validateMacAddress(string $attribute, mixed $value)

Validate that an attribute is a valid MAC address.

bool
validateJson(string $attribute, mixed $value)

Validate the attribute is a valid JSON string.

bool
validateMax(string $attribute, mixed $value, mixed $parameters)

Validate the size of an attribute is less than or equal to a maximum value.

bool
validateMaxDigits(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute has a maximum number of digits.

bool
validateMimes(string $attribute, mixed $value, mixed $parameters)

Validate the guessed extension of a file upload is in a set of file extensions.

bool
validateMimetypes(string $attribute, mixed $value, mixed $parameters)

Validate the MIME type of a file upload attribute is in a set of MIME types.

bool
shouldBlockPhpUpload(mixed $value, array $parameters)

Check if PHP uploads are explicitly allowed.

bool
validateMin(string $attribute, mixed $value, mixed $parameters)

Validate the size of an attribute is greater than or equal to a minimum value.

bool
validateMinDigits(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute has a minimum number of digits.

bool
validateMissing(mixed $attribute, mixed $value, array<int, int|string> $parameters)

Validate that an attribute is missing.

bool
validateMissingIf(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute is missing when another attribute has a given value.

bool
validateMissingUnless(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute is missing unless another attribute has a given value.

bool
validateMissingWith(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute is missing when any given attribute is present.

bool
validateMissingWithAll(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute is missing when all given attributes are present.

bool
validateMultipleOf(string $attribute, mixed $value, mixed $parameters)

Validate the value of an attribute is a multiple of a given value.

bool
validateNullable()

"Indicate" validation should pass if value is null.

bool
validateNotIn(string $attribute, mixed $value, mixed $parameters)

Validate an attribute is not contained within a list of values.

bool
validateNumeric(string $attribute, mixed $value, array $parameters = [])

Validate that an attribute is numeric.

bool
validatePresent(string $attribute, mixed $value)

Validate that an attribute exists even if not filled.

bool
validatePresentIf(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute is present when another attribute has a given value.

bool
validatePresentUnless(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute is present unless another attribute has a given value.

bool
validatePresentWith(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute is present when any given attribute is present.

bool
validatePresentWithAll(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute is present when all given attributes are present.

bool
validateRegex(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute passes a regular expression check.

bool
validateNotRegex(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute does not pass a regular expression check.

bool
validateRequired(string $attribute, mixed $value)

Validate that a required attribute exists.

bool
validateRequiredIf(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute exists when another attribute has a given value.

bool
validateRequiredIfAccepted(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute exists when another attribute was "accepted".

bool
validateRequiredIfDeclined(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute exists when another attribute was "declined".

bool
validateProhibited(string $attribute, mixed $value)

Validate that an attribute does not exist or is an empty string.

bool
validateProhibitedIf(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute does not exist when another attribute has a given value.

bool
validateProhibitedIfAccepted(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute does not exist when another attribute was "accepted".

bool
validateProhibitedIfDeclined(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute does not exist when another attribute was "declined".

bool
validateProhibitedUnless(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute does not exist unless another attribute has a given value.

bool
validateProhibits(string $attribute, mixed $value, mixed $parameters)

Validate that other attributes do not exist when this attribute exists.

bool
validateExclude()

Indicate that an attribute is excluded.

bool
validateExcludeIf(string $attribute, mixed $value, mixed $parameters)

Indicate that an attribute should be excluded when another attribute has a given value.

bool
validateExcludeUnless(string $attribute, mixed $value, mixed $parameters)

Indicate that an attribute should be excluded when another attribute does not have a given value.

bool
validateRequiredUnless(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute exists when another attribute does not have a given value.

bool
validateExcludeWith(string $attribute, mixed $value, mixed $parameters)

Indicate that an attribute should be excluded when another attribute presents.

bool
validateExcludeWithout(string $attribute, mixed $value, mixed $parameters)

Indicate that an attribute should be excluded when another attribute is missing.

array
parseDependentRuleParameters(array $parameters)

Prepare the values and the other value for validation.

bool
shouldConvertToBoolean(string $parameter)

Check if parameter should be converted to boolean.

array
convertValuesToBoolean(array $values)

Convert the given values to boolean if they are string "true" / "false".

array
convertValuesToNull(array $values)

Convert the given values to null if they are string "null".

bool
validateRequiredWith(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute exists when any other attribute exists.

bool
validateRequiredWithAll(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute exists when all other attributes exist.

bool
validateRequiredWithout(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute exists when another attribute does not.

bool
validateRequiredWithoutAll(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute exists when all other attributes do not.

bool
anyFailingRequired(array $attributes)

Determine if any of the given attributes fail the required test.

bool
allFailingRequired(array $attributes)

Determine if all of the given attributes fail the required test.

bool
validateSame(string $attribute, mixed $value, mixed $parameters)

Validate that two attributes match.

bool
validateSize(string $attribute, mixed $value, mixed $parameters)

Validate the size of an attribute.

bool
validateSometimes()

"Validate" optional attributes.

bool
validateStartsWith(string $attribute, mixed $value, mixed $parameters)

Validate the attribute starts with a given substring.

bool
validateDoesntStartWith(string $attribute, mixed $value, mixed $parameters)

Validate the attribute does not start with a given substring.

bool
validateEndsWith(string $attribute, mixed $value, mixed $parameters)

Validate the attribute ends with a given substring.

bool
validateDoesntEndWith(string $attribute, mixed $value, mixed $parameters)

Validate the attribute does not end with a given substring.

bool
validateString(string $attribute, mixed $value)

Validate that an attribute is a string.

bool
validateTimezone(string $attribute, mixed $value, array $parameters = [])

Validate that an attribute is a valid timezone.

bool
validateUrl(string $attribute, mixed $value, array $parameters = [])

Validate that an attribute is a valid URL.

bool
validateUlid(string $attribute, mixed $value)

Validate that an attribute is a valid ULID.

bool
isValidUlid(string $value)

Determine if a value is a valid ULID.

bool
validateUuid(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute is a valid UUID.

bool
isValidUuid(string $value)

Determine if a value is a valid UUID (any version).

float|int|string
getSize(string $attribute, mixed $value)

Get the size of an attribute.

float|int|string
sizeOf(string $attribute, mixed $value, bool $numeric)

Compute the validation size from numeric semantics and runtime value shape.

bool
isValidFileInstance(mixed $value)

Check that the given value is a valid file instance.

bool
compare(mixed $first, mixed $second, string $operator)

Determine if a comparison passes between the given values.

array|null
parseNamedParameters(array $parameters)

Parse named parameters to $key => $value items.

void
requireParameterCount(int $count, array $parameters, string $rule)

Require a certain number of parameters to be present.

bool
isSameType(mixed $first, mixed $second)

Check if the parameters are of the same type.

void
shouldBeNumeric(string $attribute, string $rule)

Adds the existing rule to the numericRules array if the attribute's value is numeric.

mixed
trim(mixed $value)

Trim the value if it is a string.

mixed
ensureExponentWithinAllowedRange(string $attribute, mixed $value)

Ensure the exponent is within the allowed range.

Details

at line 49
bool validateAccepted(string $attribute, mixed $value)

Validate that an attribute was "accepted".

This validation rule implies the attribute is "required".

Parameters

string $attribute
mixed $value

Return Value

bool

at line 59
bool validateAcceptedIf(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute was "accepted" when another attribute has a given value.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

at line 79
bool validateDeclined(string $attribute, mixed $value)

Validate that an attribute was "declined".

This validation rule implies the attribute is "required".

Parameters

string $attribute
mixed $value

Return Value

bool

at line 89
bool validateDeclinedIf(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute was "declined" when another attribute has a given value.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

at line 107
bool validateActiveUrl(string $attribute, mixed $value)

Validate that an attribute is an active URL.

Parameters

string $attribute
mixed $value

Return Value

bool

at line 131
protected array|false getDnsRecords(string $hostname, int $type)

Get the DNS records for the given hostname.

Parameters

string $hostname
int $type

Return Value

array|false

at line 150
bool validateAscii(string $attribute, mixed $value)

Validate that an attribute is 7 bit ASCII.

Parameters

string $attribute
mixed $value

Return Value

bool

at line 158
bool validateBase64(string $attribute, mixed $value)

Validate that an attribute is a valid Base64 string.

Parameters

string $attribute
mixed $value

Return Value

bool

at line 174
bool validateBail()

"Break" on first validation fail.

Always returns true, just lets us put "bail" in rules.

Return Value

bool

at line 184
bool validateBefore(string $attribute, mixed $value, mixed $parameters)

Validate the date is before a given date.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

at line 196
bool validateBeforeOrEqual(string $attribute, mixed $value, mixed $parameters)

Validate the date is before or equal a given date.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

at line 208
bool validateAfter(string $attribute, mixed $value, mixed $parameters)

Validate the date is after a given date.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

at line 220
bool validateAfterOrEqual(string $attribute, mixed $value, mixed $parameters)

Validate the date is equal or after a given date.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

at line 232
protected bool compareDates(string $attribute, mixed $value, array $parameters, string $operator)

Compare a given date against another using an operator.

Parameters

string $attribute
mixed $value
array $parameters
string $operator

Return Value

bool

at line 262
protected string|null getDateFormat(string $attribute)

Get the date format for an attribute if it has one.

Parameters

string $attribute

Return Value

string|null

at line 278
protected int|null getDateTimestamp(mixed $value)

Get the date timestamp.

Parameters

mixed $value

Return Value

int|null

at line 293
protected bool checkDateTimeOrder(string $format, mixed $value, mixed $argument, string $operator)

Compare a date value with a literal or referenced field using the given format.

Parameters

string $format
mixed $value
mixed $argument
string $operator

Return Value

bool

at line 326
protected DateTimeInterface|null getDateTimeWithOptionalFormat(string $format, mixed $value)

Get a DateTime instance from a supported value using the given format.

Parameters

string $format
mixed $value

Return Value

DateTimeInterface|null

at line 346
protected DateTimeInterface|null getDateTime(DateTimeInterface|float|int|string $value)

Get a DateTime instance from a string with no format.

Parameters

DateTimeInterface|float|int|string $value

Return Value

DateTimeInterface|null

at line 362
bool validateAlpha(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute contains only alphabetic characters.

If the 'ascii' option is passed, validate that an attribute contains only ascii alphabetic characters.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

at line 378
bool validateAlphaDash(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute contains only alpha-numeric characters, dashes, and underscores.

If the 'ascii' option is passed, validate that an attribute contains only ascii alpha-numeric characters, dashes, and underscores.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

at line 397
bool validateAlphaNum(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute contains only alpha-numeric characters.

If the 'ascii' option is passed, validate that an attribute contains only ascii alpha-numeric characters.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

at line 415
bool validateArray(string $attribute, mixed $value, array $parameters = [])

Validate that an attribute is an array.

Parameters

string $attribute
mixed $value
array $parameters

Return Value

bool

at line 434
protected array acceptedArrayKeys(array $parameters)

Get the accepted literal and encoded array keys.

Parameters

array $parameters

Return Value

array

at line 447
bool validateArrayKeys(string $attribute, mixed $value, array $parameters)

Validate that an array does not contain any keys other than the given keys.

Parameters

string $attribute
mixed $value
array $parameters

Return Value

bool

at line 461
bool validateList(string $attribute, mixed $value)

Validate that an attribute is a list.

Parameters

string $attribute
mixed $value

Return Value

bool

at line 471
bool validateRequiredArrayKeys(string $attribute, mixed $value, array $parameters)

Validate that an array has all of the given keys.

Parameters

string $attribute
mixed $value
array $parameters

Return Value

bool

at line 492
bool validateBetween(string $attribute, mixed $value, array $parameters)

Validate the size of an attribute is between a set of values.

Parameters

string $attribute
mixed $value
array $parameters

Return Value

bool

at line 511
bool validateBoolean(string $attribute, mixed $value, array $parameters)

Validate that an attribute is a boolean.

Parameters

string $attribute
mixed $value
array $parameters

Return Value

bool

at line 527
bool validateConfirmed(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute has a matching confirmation.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

at line 537
bool validateContains(string $attribute, mixed $value, mixed $parameters)

Validate an attribute contains a list of values.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

at line 558
bool validateDoesntContain(string $attribute, mixed $value, mixed $parameters)

Validate an attribute does not contain a list of values.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

at line 579
protected bool validateCurrentPassword(string $attribute, mixed $value, mixed $parameters)

Validate that the password of the currently authenticated user matches the given value.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

at line 596
bool validateDate(string $attribute, mixed $value)

Validate that an attribute is a valid date.

Parameters

string $attribute
mixed $value

Return Value

bool

at line 608
protected bool isValidDate(mixed $value)

Determine if a value is a valid date.

Accepts DateTimeInterface instances, numeric timestamps, and string date representations. Validates via strtotime() and date_parse() + checkdate() to reject dates like February 30th.

Parameters

mixed $value

Return Value

bool

at line 632
bool validateDateFormat(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute matches a date format.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

at line 655
protected bool matchesDateFormat(mixed $value, string $format)

Determine if a value matches a specific date format.

Creates a DateTime from the format and verifies round-trip formatting produces the same string. Catches ValueError for invalid format strings.

Parameters

mixed $value
string $format

Return Value

bool

at line 676
bool validateDateEquals(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute is equal to another date.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

at line 688
bool validateDecimal(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute has a given number of decimal places.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

at line 717
bool validateDifferent(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute is different from another attribute.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

at line 739
bool validateDigits(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute has a given number of digits.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

at line 753
bool validateDigitsBetween(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute is between a given number of digits.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

at line 772
bool validateDimensions(string $attribute, mixed $value, mixed $parameters)

Validate the dimensions of an image matches the given values.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

at line 809
protected bool failsBasicDimensionChecks(array $parameters, int $width, int $height)

Test if the given width and height fail any conditions.

Parameters

array $parameters
int $width
int $height

Return Value

bool

at line 822
protected bool failsRatioCheck(array $parameters, int $width, int $height)

Determine if the given parameters fail a dimension ratio check.

Parameters

array $parameters
int $width
int $height

Return Value

bool

at line 881
bool validateDistinct(string $attribute, mixed $value, mixed $parameters)

Validate an attribute is unique among other values.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

at line 947
protected string|null getDistinctValueKey(mixed $value)

Identify values whose strict equality can be counted without comparing every sibling.

Parameters

mixed $value

Return Value

string|null

at line 965
protected array getDistinctValues(string $attribute)

Get the values to distinct between.

Parameters

string $attribute

Return Value

array

at line 984
protected array extractDistinctValues(string $attribute)

Extract the distinct values from the data.

Parameters

string $attribute

Return Value

array

at line 1003
bool validateEmail(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute is a valid e-mail address.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

at line 1042
protected bool isValidEmail(string $value)

Determine if a value is a valid email address using basic RFC validation.

Used by the inline check for the bare email rule token. The parameterized form (email:rfc,dns,spoof,filter,...) stays in validateEmail() and flows through the delegated path.

Parameters

string $value

Return Value

bool

at line 1060
bool validateEncoding(string $attribute, mixed $value, array $parameters)

Validate the encoding of an attribute.

Parameters

string $attribute
mixed $value
array $parameters

Return Value

bool

Exceptions

InvalidArgumentException

at line 1082
bool validateExists(string $attribute, mixed $value, mixed $parameters)

Validate the existence of an attribute value in a database table.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

at line 1122
protected int getExistCount(mixed $connection, string $table, string $column, mixed $value, array $parameters)

Get the number of records that exist in storage.

Parameters

mixed $connection
string $table
string $column
mixed $value
array $parameters

Return Value

int

at line 1146
bool validateUnique(string $attribute, mixed $value, mixed $parameters)

Validate the uniqueness of an attribute value on a given database table.

If a database column is not specified, the attribute will be used.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

at line 1193
protected array getUniqueIds(string|null $idColumn, array $parameters)

Get the excluded ID column and value for the unique rule.

Parameters

string|null $idColumn
array $parameters

Return Value

array

at line 1203
protected int|string|null prepareUniqueId(mixed $id)

Prepare the given ID for querying.

Parameters

mixed $id

Return Value

int|string|null

at line 1225
protected array getUniqueExtra(array $parameters)

Get the extra conditions for a unique rule.

Parameters

array $parameters

Return Value

array

at line 1239
array parseTable(string $table)

Parse the connection / table for the unique / exists rules.

Parameters

string $table

Return Value

array

at line 1267
bool|string getQueryColumn(array $parameters, string $attribute)

Get the column name for an exists / unique query.

Parameters

array $parameters
string $attribute

Return Value

bool|string

at line 1277
string guessColumnForQuery(string $attribute)

Guess the database column from the given attribute name.

Parameters

string $attribute

Return Value

string

at line 1291
protected array getExtraConditions(array $segments)

Get the extra conditions for a unique / exists rule.

Parameters

array $segments

Return Value

array

at line 1309
bool validateExtensions(string $attribute, mixed $value, array $parameters)

Validate the extension of a file upload attribute is in a set of defined extensions.

Parameters

string $attribute
mixed $value
array $parameters

Return Value

bool

at line 1325
bool validateFile(string $attribute, mixed $value)

Validate the given value is a valid file.

Parameters

string $attribute
mixed $value

Return Value

bool

at line 1333
bool validateFilled(string $attribute, mixed $value)

Validate the given attribute is filled if it is present.

Parameters

string $attribute
mixed $value

Return Value

bool

at line 1347
bool validateGt(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute is greater than another attribute.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

at line 1393
bool validateLt(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute is less than another attribute.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

at line 1439
bool validateGte(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute is greater than or equal another attribute.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

at line 1485
bool validateLte(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute is less than or equal another attribute.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

at line 1529
bool validateLowercase(string $attribute, mixed $value)

Validate that an attribute is lowercase.

Parameters

string $attribute
mixed $value

Return Value

bool

at line 1537
bool validateUppercase(string $attribute, mixed $value)

Validate that an attribute is uppercase.

Parameters

string $attribute
mixed $value

Return Value

bool

at line 1545
bool validateHexColor(string $attribute, mixed $value)

Validate that an attribute is a valid HEX color.

Parameters

string $attribute
mixed $value

Return Value

bool

at line 1556
bool validateImage(string $attribute, mixed $value, array $parameters = [])

Validate the MIME type of a file is an image MIME type.

Parameters

string $attribute
mixed $value
array $parameters

Return Value

bool

at line 1572
bool validateIn(string $attribute, mixed $value, mixed $parameters)

Validate an attribute is contained within a list of values.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

at line 1600
bool validateInArray(string $attribute, mixed $value, mixed $parameters)

Validate that the values of an attribute are in another attribute.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

at line 1620
bool validateInArrayKeys(string $attribute, mixed $value, array $parameters)

Validate that an array contains at least one of the given keys.

Parameters

string $attribute
mixed $value
array $parameters

Return Value

bool

at line 1645
bool validateInteger(string $attribute, mixed $value, array $parameters = [])

Validate that an attribute is an integer.

Parameters

string $attribute
mixed $value
array $parameters

Return Value

bool

at line 1657
bool validateIp(string $attribute, mixed $value)

Validate that an attribute is a valid IP.

Parameters

string $attribute
mixed $value

Return Value

bool

at line 1665
bool validateIpv4(string $attribute, mixed $value)

Validate that an attribute is a valid IPv4.

Parameters

string $attribute
mixed $value

Return Value

bool

at line 1673
bool validateIpv6(string $attribute, mixed $value)

Validate that an attribute is a valid IPv6.

Parameters

string $attribute
mixed $value

Return Value

bool

at line 1681
protected bool isValidIp(string $value)

Determine if a value is a valid IP address (any version).

Parameters

string $value

Return Value

bool

at line 1689
protected bool isValidIpv4(string $value)

Determine if a value is a valid IPv4 address.

Parameters

string $value

Return Value

bool

at line 1697
protected bool isValidIpv6(string $value)

Determine if a value is a valid IPv6 address.

Parameters

string $value

Return Value

bool

at line 1705
bool validateMacAddress(string $attribute, mixed $value)

Validate that an attribute is a valid MAC address.

Parameters

string $attribute
mixed $value

Return Value

bool

at line 1713
bool validateJson(string $attribute, mixed $value)

Validate the attribute is a valid JSON string.

Parameters

string $attribute
mixed $value

Return Value

bool

at line 1727
bool validateMax(string $attribute, mixed $value, mixed $parameters)

Validate the size of an attribute is less than or equal to a maximum value.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

at line 1747
bool validateMaxDigits(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute has a maximum number of digits.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

at line 1765
bool validateMimes(string $attribute, mixed $value, mixed $parameters)

Validate the guessed extension of a file upload is in a set of file extensions.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

at line 1787
bool validateMimetypes(string $attribute, mixed $value, mixed $parameters)

Validate the MIME type of a file upload attribute is in a set of MIME types.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

at line 1807
protected bool shouldBlockPhpUpload(mixed $value, array $parameters)

Check if PHP uploads are explicitly allowed.

Parameters

mixed $value
array $parameters

Return Value

bool

at line 1834
bool validateMin(string $attribute, mixed $value, mixed $parameters)

Validate the size of an attribute is greater than or equal to a minimum value.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

at line 1850
bool validateMinDigits(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute has a minimum number of digits.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

at line 1870
bool validateMissing(mixed $attribute, mixed $value, array<int, int|string> $parameters)

Validate that an attribute is missing.

Parameters

mixed $attribute
mixed $value
array<int, int|string> $parameters

Return Value

bool

at line 1880
bool validateMissingIf(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute is missing when another attribute has a given value.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

at line 1898
bool validateMissingUnless(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute is missing unless another attribute has a given value.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

at line 1916
bool validateMissingWith(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute is missing when any given attribute is present.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

at line 1932
bool validateMissingWithAll(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute is missing when all given attributes are present.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

at line 1948
bool validateMultipleOf(string $attribute, mixed $value, mixed $parameters)

Validate the value of an attribute is a multiple of a given value.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

at line 1985
bool validateNullable()

"Indicate" validation should pass if value is null.

Always returns true, just lets us put "nullable" in rules.

Return Value

bool

at line 1995
bool validateNotIn(string $attribute, mixed $value, mixed $parameters)

Validate an attribute is not contained within a list of values.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

at line 2005
bool validateNumeric(string $attribute, mixed $value, array $parameters = [])

Validate that an attribute is numeric.

Parameters

string $attribute
mixed $value
array $parameters

Return Value

bool

at line 2017
bool validatePresent(string $attribute, mixed $value)

Validate that an attribute exists even if not filled.

Parameters

string $attribute
mixed $value

Return Value

bool

at line 2027
bool validatePresentIf(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute is present when another attribute has a given value.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

at line 2045
bool validatePresentUnless(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute is present unless another attribute has a given value.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

at line 2063
bool validatePresentWith(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute is present when any given attribute is present.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

at line 2079
bool validatePresentWithAll(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute is present when all given attributes are present.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

at line 2095
bool validateRegex(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute passes a regular expression check.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

at line 2111
bool validateNotRegex(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute does not pass a regular expression check.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

at line 2125
bool validateRequired(string $attribute, mixed $value)

Validate that a required attribute exists.

Parameters

string $attribute
mixed $value

Return Value

bool

at line 2146
bool validateRequiredIf(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute exists when another attribute has a given value.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

at line 2166
bool validateRequiredIfAccepted(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute exists when another attribute was "accepted".

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

at line 2180
bool validateRequiredIfDeclined(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute exists when another attribute was "declined".

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

at line 2194
bool validateProhibited(string $attribute, mixed $value)

Validate that an attribute does not exist or is an empty string.

Parameters

string $attribute
mixed $value

Return Value

bool

at line 2202
bool validateProhibitedIf(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute does not exist when another attribute has a given value.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

at line 2218
bool validateProhibitedIfAccepted(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute does not exist when another attribute was "accepted".

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

at line 2232
bool validateProhibitedIfDeclined(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute does not exist when another attribute was "declined".

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

at line 2246
bool validateProhibitedUnless(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute does not exist unless another attribute has a given value.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

at line 2262
bool validateProhibits(string $attribute, mixed $value, mixed $parameters)

Validate that other attributes do not exist when this attribute exists.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

at line 2278
bool validateExclude()

Indicate that an attribute is excluded.

Return Value

bool

at line 2286
bool validateExcludeIf(string $attribute, mixed $value, mixed $parameters)

Indicate that an attribute should be excluded when another attribute has a given value.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

at line 2302
bool validateExcludeUnless(string $attribute, mixed $value, mixed $parameters)

Indicate that an attribute should be excluded when another attribute does not have a given value.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

at line 2314
bool validateRequiredUnless(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute exists when another attribute does not have a given value.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

at line 2330
bool validateExcludeWith(string $attribute, mixed $value, mixed $parameters)

Indicate that an attribute should be excluded when another attribute presents.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

at line 2344
bool validateExcludeWithout(string $attribute, mixed $value, mixed $parameters)

Indicate that an attribute should be excluded when another attribute is missing.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

at line 2360
array parseDependentRuleParameters(array $parameters)

Prepare the values and the other value for validation.

Parameters

array $parameters

Return Value

array

at line 2380
protected bool shouldConvertToBoolean(string $parameter)

Check if parameter should be converted to boolean.

Parameters

string $parameter

Return Value

bool

at line 2388
protected array convertValuesToBoolean(array $values)

Convert the given values to boolean if they are string "true" / "false".

Parameters

array $values

Return Value

array

at line 2400
protected array convertValuesToNull(array $values)

Convert the given values to null if they are string "null".

Parameters

array $values

Return Value

array

at line 2410
bool validateRequiredWith(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute exists when any other attribute exists.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

at line 2422
bool validateRequiredWithAll(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute exists when all other attributes exist.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

at line 2434
bool validateRequiredWithout(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute exists when another attribute does not.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

at line 2446
bool validateRequiredWithoutAll(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute exists when all other attributes do not.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

at line 2458
protected bool anyFailingRequired(array $attributes)

Determine if any of the given attributes fail the required test.

Parameters

array $attributes

Return Value

bool

at line 2473
protected bool allFailingRequired(array $attributes)

Determine if all of the given attributes fail the required test.

Parameters

array $attributes

Return Value

bool

at line 2490
bool validateSame(string $attribute, mixed $value, mixed $parameters)

Validate that two attributes match.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

at line 2504
bool validateSize(string $attribute, mixed $value, mixed $parameters)

Validate the size of an attribute.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

at line 2520
bool validateSometimes()

"Validate" optional attributes.

Always returns true, just lets us put sometimes in rules.

Return Value

bool

at line 2530
bool validateStartsWith(string $attribute, mixed $value, mixed $parameters)

Validate the attribute starts with a given substring.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

at line 2544
bool validateDoesntStartWith(string $attribute, mixed $value, mixed $parameters)

Validate the attribute does not start with a given substring.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

at line 2558
bool validateEndsWith(string $attribute, mixed $value, mixed $parameters)

Validate the attribute ends with a given substring.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

at line 2572
bool validateDoesntEndWith(string $attribute, mixed $value, mixed $parameters)

Validate the attribute does not end with a given substring.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

at line 2584
bool validateString(string $attribute, mixed $value)

Validate that an attribute is a string.

Parameters

string $attribute
mixed $value

Return Value

bool

at line 2594
bool validateTimezone(string $attribute, mixed $value, array $parameters = [])

Validate that an attribute is a valid timezone.

Parameters

string $attribute
mixed $value
array $parameters

Return Value

bool

at line 2614
bool validateUrl(string $attribute, mixed $value, array $parameters = [])

Validate that an attribute is a valid URL.

Parameters

string $attribute
mixed $value
array $parameters

Return Value

bool

at line 2622
bool validateUlid(string $attribute, mixed $value)

Validate that an attribute is a valid ULID.

Parameters

string $attribute
mixed $value

Return Value

bool

at line 2630
protected bool isValidUlid(string $value)

Determine if a value is a valid ULID.

Parameters

string $value

Return Value

bool

at line 2640
bool validateUuid(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute is a valid UUID.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

at line 2662
protected bool isValidUuid(string $value)

Determine if a value is a valid UUID (any version).

Used by the inline check for the bare uuid rule token. The parameterized form (uuid:4, uuid:max) stays in validateUuid() and flows through the delegated path.

Parameters

string $value

Return Value

bool

at line 2670
protected float|int|string getSize(string $attribute, mixed $value)

Get the size of an attribute.

Parameters

string $attribute
mixed $value

Return Value

float|int|string

at line 2682
protected float|int|string sizeOf(string $attribute, mixed $value, bool $numeric)

Compute the validation size from numeric semantics and runtime value shape.

Parameters

string $attribute
mixed $value
bool $numeric

Return Value

float|int|string

at line 2702
bool isValidFileInstance(mixed $value)

Check that the given value is a valid file instance.

Parameters

mixed $value

Return Value

bool

at line 2716
protected bool compare(mixed $first, mixed $second, string $operator)

Determine if a comparison passes between the given values.

Parameters

mixed $first
mixed $second
string $operator

Return Value

bool

Exceptions

InvalidArgumentException

at line 2735
array|null parseNamedParameters(array $parameters)

Parse named parameters to $key => $value items.

Parameters

array $parameters

Return Value

array|null

at line 2751
void requireParameterCount(int $count, array $parameters, string $rule)

Require a certain number of parameters to be present.

Parameters

int $count
array $parameters
string $rule

Return Value

void

Exceptions

InvalidArgumentException

at line 2761
protected bool isSameType(mixed $first, mixed $second)

Check if the parameters are of the same type.

Parameters

mixed $first
mixed $second

Return Value

bool

at line 2769
protected void shouldBeNumeric(string $attribute, string $rule)

Adds the existing rule to the numericRules array if the attribute's value is numeric.

Parameters

string $attribute
string $rule

Return Value

void

at line 2779
protected mixed trim(mixed $value)

Trim the value if it is a string.

Parameters

mixed $value

Return Value

mixed

at line 2787
protected mixed ensureExponentWithinAllowedRange(string $attribute, mixed $value)

Ensure the exponent is within the allowed range.

Parameters

string $attribute
mixed $value

Return Value

mixed