trait ValidatesAttributes (View source)

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
validateBail()

"Break" on first validation fail.

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

Validate the date is before a given date.

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

Validate the date is before or equal a given date.

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

Validate the date is after a given date.

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

Validate the date is equal or after a given date.

bool
compareDates(string $attribute, mixed $value, array<int,int|string> $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
getDateTimestamp(mixed $value)

Get the date timestamp.

bool
checkDateTimeOrder(string $format, string $first, string $second, string $operator)

Given two date/time strings, check that one is after the other.

DateTime|null
getDateTimeWithOptionalFormat(string $format, string $value)

Get a DateTime instance from a string.

DateTime|null
getDateTime(string $value)

Get a DateTime instance from a string with no format.

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

Validate that an attribute contains only alphabetic characters.

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

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

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

Validate that an attribute contains only alpha-numeric characters.

bool
validateArray(string $attribute, mixed $value, array<int,int|string> $parameters = [])

Validate that an attribute is an array.

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

Validate that an array has all of the given keys.

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

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

bool
validateBoolean(string $attribute, mixed $value)

Validate that an attribute is a boolean.

bool
validateConfirmed(string $attribute, mixed $value)

Validate that an attribute has a matching confirmation.

bool
validateCurrentPassword(string $attribute, mixed $value, array<int,int|string> $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
validateDateFormat(string $attribute, mixed $value, array<int,int|string> $parameters)

Validate that an attribute matches a date format.

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

Validate that an attribute is equal to another date.

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

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

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

Validate that an attribute is different from another attribute.

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

Validate that an attribute has a given number of digits.

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

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

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

Validate the dimensions of an image matches the given values.

bool
failsBasicDimensionChecks(array<string,string> $parameters, int $width, int $height)

Test if the given width and height fail any conditions.

bool
failsRatioCheck(array<string,string> $parameters, int $width, int $height)

Determine if the given parameters fail a dimension ratio check.

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

Validate an attribute is unique among other values.

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, array<int,int|string> $parameters)

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

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

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

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

Get the number of records that exist in storage.

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

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

array
getUniqueIds(string|null $idColumn, array<int,int|string> $parameters)

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

int
prepareUniqueId(mixed $id)

Prepare the given ID for querying.

array
getUniqueExtra(array<int,int|string> $parameters)

Get the extra conditions for a unique rule.

array
parseTable(string $table)

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

bool
getQueryColumn(array<int,int|string> $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
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, array<int,int|string> $parameters)

Validate that an attribute is greater than another attribute.

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

Validate that an attribute is less than another attribute.

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

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

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

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

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

Validate that an attribute is lowercase.

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

Validate that an attribute is uppercase.

bool
validateImage(string $attribute, mixed $value)

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

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

Validate an attribute is contained within a list of values.

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

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

bool
validateInteger(string $attribute, mixed $value)

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
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, array<int,int|string> $parameters)

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

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

Validate that an attribute has a maximum number of digits.

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

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

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

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

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

Check if PHP uploads are explicitly allowed.

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

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

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

Validate that an attribute has a minimum number of digits.

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

Validate that an attribute is missing.

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

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

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

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

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

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

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

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

bool
validateMultipleOf(string $attribute, mixed $value, array<int,int|string> $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, array<int,int|string> $parameters)

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

bool
validateNumeric(string $attribute, mixed $value)

Validate that an attribute is numeric.

bool
validatePresent(string $attribute, mixed $value)

Validate that an attribute exists even if not filled.

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

Validate that an attribute passes a regular expression check.

bool
validateNotRegex(string $attribute, mixed $value, array<int,int|string> $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
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
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<int,int|string> $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, array<int,int|string> $parameters)

Validate that two attributes match.

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

Validate the size of an attribute.

bool
validateSometimes()

"Validate" optional attributes.

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

Validate the attribute starts with a given substring.

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

Validate the attribute does not start with a given substring.

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

Validate the attribute ends with a given substring.

bool
validateDoesntEndWith(string $attribute, mixed $value, array<int,int|string> $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)

Validate that an attribute is a valid timezone.

bool
validateUrl(string $attribute, mixed $value)

Validate that an attribute is a valid URL.

bool
validateUlid(string $attribute, mixed $value)

Validate that an attribute is a valid ULID.

bool
validateUuid(string $attribute, mixed $value)

Validate that an attribute is a valid UUID.

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

Get the size of an attribute.

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
parseNamedParameters(array<int,int|string> $parameters)

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

void
requireParameterCount(int $count, array<int,int|string> $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.

Details

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

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

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

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

bool validateActiveUrl(string $attribute, mixed $value)

Validate that an attribute is an active URL.

Parameters

string $attribute
mixed $value

Return Value

bool

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

bool validateAscii(string $attribute, mixed $value)

Validate that an attribute is 7 bit ASCII.

Parameters

string $attribute
mixed $value

Return Value

bool

bool validateBail()

"Break" on first validation fail.

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

Return Value

bool

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

Validate the date is before a given date.

Parameters

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

Return Value

bool

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

Validate the date is before or equal a given date.

Parameters

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

Return Value

bool

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

Validate the date is after a given date.

Parameters

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

Return Value

bool

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

Validate the date is equal or after a given date.

Parameters

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

Return Value

bool

protected bool compareDates(string $attribute, mixed $value, array<int,int|string> $parameters, string $operator)

Compare a given date against another using an operator.

Parameters

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

Return Value

bool

protected string|null getDateFormat(string $attribute)

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

Parameters

string $attribute

Return Value

string|null

protected int getDateTimestamp(mixed $value)

Get the date timestamp.

Parameters

mixed $value

Return Value

int

protected bool checkDateTimeOrder(string $format, string $first, string $second, string $operator)

Given two date/time strings, check that one is after the other.

Parameters

string $format
string $first
string $second
string $operator

Return Value

bool

protected DateTime|null getDateTimeWithOptionalFormat(string $format, string $value)

Get a DateTime instance from a string.

Parameters

string $format
string $value

Return Value

DateTime|null

protected DateTime|null getDateTime(string $value)

Get a DateTime instance from a string with no format.

Parameters

string $value

Return Value

DateTime|null

bool validateAlpha(string $attribute, mixed $value, $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
$parameters

Return Value

bool

bool validateAlphaDash(string $attribute, mixed $value, $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
$parameters

Return Value

bool

bool validateAlphaNum(string $attribute, mixed $value, $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
$parameters

Return Value

bool

bool validateArray(string $attribute, mixed $value, array<int,int|string> $parameters = [])

Validate that an attribute is an array.

Parameters

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

Return Value

bool

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

Validate that an array has all of the given keys.

Parameters

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

Return Value

bool

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

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

Parameters

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

Return Value

bool

bool validateBoolean(string $attribute, mixed $value)

Validate that an attribute is a boolean.

Parameters

string $attribute
mixed $value

Return Value

bool

bool validateConfirmed(string $attribute, mixed $value)

Validate that an attribute has a matching confirmation.

Parameters

string $attribute
mixed $value

Return Value

bool

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

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

Parameters

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

Return Value

bool

bool validateDate(string $attribute, mixed $value)

Validate that an attribute is a valid date.

Parameters

string $attribute
mixed $value

Return Value

bool

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

Validate that an attribute matches a date format.

Parameters

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

Return Value

bool

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

Validate that an attribute is equal to another date.

Parameters

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

Return Value

bool

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

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

Parameters

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

Return Value

bool

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

Validate that an attribute is different from another attribute.

Parameters

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

Return Value

bool

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

Validate that an attribute has a given number of digits.

Parameters

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

Return Value

bool

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

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

Parameters

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

Return Value

bool

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

Validate the dimensions of an image matches the given values.

Parameters

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

Return Value

bool

protected bool failsBasicDimensionChecks(array<string,string> $parameters, int $width, int $height)

Test if the given width and height fail any conditions.

Parameters

array<string,string> $parameters
int $width
int $height

Return Value

bool

protected bool failsRatioCheck(array<string,string> $parameters, int $width, int $height)

Determine if the given parameters fail a dimension ratio check.

Parameters

array<string,string> $parameters
int $width
int $height

Return Value

bool

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

Validate an attribute is unique among other values.

Parameters

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

Return Value

bool

protected array getDistinctValues(string $attribute)

Get the values to distinct between.

Parameters

string $attribute

Return Value

array

protected array extractDistinctValues(string $attribute)

Extract the distinct values from the data.

Parameters

string $attribute

Return Value

array

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

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

Parameters

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

Return Value

bool

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

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

Parameters

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

Return Value

bool

protected int getExistCount(mixed $connection, string $table, string $column, mixed $value, array<int,int|string> $parameters)

Get the number of records that exist in storage.

Parameters

mixed $connection
string $table
string $column
mixed $value
array<int,int|string> $parameters

Return Value

int

bool validateUnique(string $attribute, mixed $value, array<int,int|string> $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
array<int,int|string> $parameters

Return Value

bool

protected array getUniqueIds(string|null $idColumn, array<int,int|string> $parameters)

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

Parameters

string|null $idColumn
array<int,int|string> $parameters

Return Value

array

protected int prepareUniqueId(mixed $id)

Prepare the given ID for querying.

Parameters

mixed $id

Return Value

int

protected array getUniqueExtra(array<int,int|string> $parameters)

Get the extra conditions for a unique rule.

Parameters

array<int,int|string> $parameters

Return Value

array

array parseTable(string $table)

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

Parameters

string $table

Return Value

array

bool getQueryColumn(array<int,int|string> $parameters, string $attribute)

Get the column name for an exists / unique query.

Parameters

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

Return Value

bool

string guessColumnForQuery(string $attribute)

Guess the database column from the given attribute name.

Parameters

string $attribute

Return Value

string

protected array getExtraConditions(array $segments)

Get the extra conditions for a unique / exists rule.

Parameters

array $segments

Return Value

array

bool validateFile(string $attribute, mixed $value)

Validate the given value is a valid file.

Parameters

string $attribute
mixed $value

Return Value

bool

bool validateFilled(string $attribute, mixed $value)

Validate the given attribute is filled if it is present.

Parameters

string $attribute
mixed $value

Return Value

bool

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

Validate that an attribute is greater than another attribute.

Parameters

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

Return Value

bool

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

Validate that an attribute is less than another attribute.

Parameters

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

Return Value

bool

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

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

Parameters

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

Return Value

bool

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

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

Parameters

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

Return Value

bool

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

Validate that an attribute is lowercase.

Parameters

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

Return Value

bool

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

Validate that an attribute is uppercase.

Parameters

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

Return Value

bool

bool validateImage(string $attribute, mixed $value)

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

Parameters

string $attribute
mixed $value

Return Value

bool

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

Validate an attribute is contained within a list of values.

Parameters

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

Return Value

bool

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

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

Parameters

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

Return Value

bool

bool validateInteger(string $attribute, mixed $value)

Validate that an attribute is an integer.

Parameters

string $attribute
mixed $value

Return Value

bool

bool validateIp(string $attribute, mixed $value)

Validate that an attribute is a valid IP.

Parameters

string $attribute
mixed $value

Return Value

bool

bool validateIpv4(string $attribute, mixed $value)

Validate that an attribute is a valid IPv4.

Parameters

string $attribute
mixed $value

Return Value

bool

bool validateIpv6(string $attribute, mixed $value)

Validate that an attribute is a valid IPv6.

Parameters

string $attribute
mixed $value

Return Value

bool

bool validateMacAddress(string $attribute, mixed $value)

Validate that an attribute is a valid MAC address.

Parameters

string $attribute
mixed $value

Return Value

bool

bool validateJson(string $attribute, mixed $value)

Validate the attribute is a valid JSON string.

Parameters

string $attribute
mixed $value

Return Value

bool

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

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

Parameters

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

Return Value

bool

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

Validate that an attribute has a maximum number of digits.

Parameters

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

Return Value

bool

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

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

Parameters

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

Return Value

bool

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

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

Parameters

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

Return Value

bool

protected bool shouldBlockPhpUpload(mixed $value, array<int,int|string> $parameters)

Check if PHP uploads are explicitly allowed.

Parameters

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

Return Value

bool

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

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

Parameters

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

Return Value

bool

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

Validate that an attribute has a minimum number of digits.

Parameters

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

Return Value

bool

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

Validate that an attribute is missing.

Parameters

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

Return Value

bool

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

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

Parameters

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

Return Value

bool

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

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

Parameters

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

Return Value

bool

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

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

Parameters

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

Return Value

bool

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

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

Parameters

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

Return Value

bool

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

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

Parameters

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

Return Value

bool

bool validateNullable()

"Indicate" validation should pass if value is null.

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

Return Value

bool

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

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

Parameters

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

Return Value

bool

bool validateNumeric(string $attribute, mixed $value)

Validate that an attribute is numeric.

Parameters

string $attribute
mixed $value

Return Value

bool

bool validatePresent(string $attribute, mixed $value)

Validate that an attribute exists even if not filled.

Parameters

string $attribute
mixed $value

Return Value

bool

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

Validate that an attribute passes a regular expression check.

Parameters

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

Return Value

bool

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

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

Parameters

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

Return Value

bool

bool validateRequired(string $attribute, mixed $value)

Validate that a required attribute exists.

Parameters

string $attribute
mixed $value

Return Value

bool

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

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

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

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

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

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

bool validateExclude()

Indicate that an attribute is excluded.

Return Value

bool

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

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

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

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

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

array parseDependentRuleParameters(array<int,int|string> $parameters)

Prepare the values and the other value for validation.

Parameters

array<int,int|string> $parameters

Return Value

array

protected bool shouldConvertToBoolean(string $parameter)

Check if parameter should be converted to boolean.

Parameters

string $parameter

Return Value

bool

protected array convertValuesToBoolean(array $values)

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

Parameters

array $values

Return Value

array

protected array convertValuesToNull(array $values)

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

Parameters

array $values

Return Value

array

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

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

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

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

protected bool anyFailingRequired(array $attributes)

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

Parameters

array $attributes

Return Value

bool

protected bool allFailingRequired(array $attributes)

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

Parameters

array $attributes

Return Value

bool

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

Validate that two attributes match.

Parameters

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

Return Value

bool

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

Validate the size of an attribute.

Parameters

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

Return Value

bool

bool validateSometimes()

"Validate" optional attributes.

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

Return Value

bool

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

Validate the attribute starts with a given substring.

Parameters

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

Return Value

bool

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

Validate the attribute does not start with a given substring.

Parameters

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

Return Value

bool

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

Validate the attribute ends with a given substring.

Parameters

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

Return Value

bool

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

Validate the attribute does not end with a given substring.

Parameters

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

Return Value

bool

bool validateString(string $attribute, mixed $value)

Validate that an attribute is a string.

Parameters

string $attribute
mixed $value

Return Value

bool

bool validateTimezone(string $attribute, mixed $value)

Validate that an attribute is a valid timezone.

Parameters

string $attribute
mixed $value

Return Value

bool

bool validateUrl(string $attribute, mixed $value)

Validate that an attribute is a valid URL.

Parameters

string $attribute
mixed $value

Return Value

bool

bool validateUlid(string $attribute, mixed $value)

Validate that an attribute is a valid ULID.

Parameters

string $attribute
mixed $value

Return Value

bool

bool validateUuid(string $attribute, mixed $value)

Validate that an attribute is a valid UUID.

Parameters

string $attribute
mixed $value

Return Value

bool

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

Get the size of an attribute.

Parameters

string $attribute
mixed $value

Return Value

int|float|string

bool isValidFileInstance(mixed $value)

Check that the given value is a valid file instance.

Parameters

mixed $value

Return Value

bool

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

array parseNamedParameters(array<int,int|string> $parameters)

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

Parameters

array<int,int|string> $parameters

Return Value

array

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

Require a certain number of parameters to be present.

Parameters

int $count
array<int,int|string> $parameters
string $rule

Return Value

void

Exceptions

InvalidArgumentException

protected bool isSameType(mixed $first, mixed $second)

Check if the parameters are of the same type.

Parameters

mixed $first
mixed $second

Return Value

bool

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

protected mixed trim(mixed $value)

Trim the value if it is a string.

Parameters

mixed $value

Return Value

mixed