ValidatesAttributes
Methods
validateAccepted ( $attribute , $value ) : bool
Validate that an attribute was "accepted".
Parameters
- $attribute string
- $value mixed
validateAcceptedIf ( $attribute , $value , $parameters ) : bool
Validate that an attribute was "accepted" when another attribute has a given value.
Parameters
- $attribute string
- $value mixed
- $parameters mixed
validateDeclined ( $attribute , $value ) : bool
Validate that an attribute was "declined".
Parameters
- $attribute string
- $value mixed
validateDeclinedIf ( $attribute , $value , $parameters ) : bool
Validate that an attribute was "declined" when another attribute has a given value.
Parameters
- $attribute string
- $value mixed
- $parameters mixed
validateActiveUrl ( $attribute , $value ) : bool
Validate that an attribute is an active URL.
Parameters
- $attribute string
- $value mixed
getDnsRecords ( $hostname , $type ) : array|false
Get the DNS records for the given hostname.
Parameters
- $hostname string
- $type int
validateAscii ( $attribute , $value ) : bool
Validate that an attribute is 7 bit ASCII.
Parameters
- $attribute string
- $value mixed
validateBail ( ) : bool
"Break" on first validation fail.
validateBefore ( $attribute , $value , $parameters ) : bool
Validate the date is before a given date.
Parameters
- $attribute string
- $value mixed
-
$parameters
array
|string>
validateBeforeOrEqual ( $attribute , $value , $parameters ) : bool
Validate the date is before or equal a given date.
Parameters
- $attribute string
- $value mixed
-
$parameters
array
|string>
validateAfter ( $attribute , $value , $parameters ) : bool
Validate the date is after a given date.
Parameters
- $attribute string
- $value mixed
-
$parameters
array
|string>
validateAfterOrEqual ( $attribute , $value , $parameters ) : bool
Validate the date is equal or after a given date.
Parameters
- $attribute string
- $value mixed
-
$parameters
array
|string>
compareDates ( $attribute , $value , $parameters , $operator ) : bool
Compare a given date against another using an operator.
Parameters
- $attribute string
- $value mixed
-
$parameters
array
|string> - $operator string
getDateFormat ( $attribute ) : string|null
Get the date format for an attribute if it has one.
Parameters
- $attribute string
getDateTimestamp ( $value ) : int
Get the date timestamp.
Parameters
- $value mixed
checkDateTimeOrder ( $format , $first , $second , $operator ) : bool
Given two date/time strings, check that one is after the other.
Parameters
- $format string
- $first string
- $second string
- $operator string
getDateTimeWithOptionalFormat ( $format , $value ) : DateTime |null
Get a DateTime instance from a string.
Parameters
- $format string
- $value string
getDateTime ( $value ) : DateTime |null
Get a DateTime instance from a string with no format.
Parameters
- $value string
validateAlpha ( $attribute , $value , $parameters ) : bool
Validate that an attribute contains only alphabetic characters.
Parameters
- $attribute string
- $value mixed
validateAlphaDash ( $attribute , $value , $parameters ) : bool
Validate that an attribute contains only alpha-numeric characters, dashes, and underscores.
Parameters
- $attribute string
- $value mixed
validateAlphaNum ( $attribute , $value , $parameters ) : bool
Validate that an attribute contains only alpha-numeric characters.
Parameters
- $attribute string
- $value mixed
validateArray ( $attribute , $value , $parameters ) : bool
Validate that an attribute is an array.
Parameters
- $attribute string
- $value mixed
-
$parameters
array
|string>
validateRequiredArrayKeys ( $attribute , $value , $parameters ) : bool
Validate that an array has all of the given keys.
Parameters
- $attribute string
- $value mixed
-
$parameters
array
|string>
validateBetween ( $attribute , $value , $parameters ) : bool
Validate the size of an attribute is between a set of values.
Parameters
- $attribute string
- $value mixed
-
$parameters
array
|string>
validateBoolean ( $attribute , $value ) : bool
Validate that an attribute is a boolean.
Parameters
- $attribute string
- $value mixed
validateConfirmed ( $attribute , $value ) : bool
Validate that an attribute has a matching confirmation.
Parameters
- $attribute string
- $value mixed
validateCurrentPassword ( $attribute , $value , $parameters ) : bool
Validate that the password of the currently authenticated user matches the given value.
Parameters
- $attribute string
- $value mixed
-
$parameters
array
|string>
validateDate ( $attribute , $value ) : bool
Validate that an attribute is a valid date.
Parameters
- $attribute string
- $value mixed
validateDateFormat ( $attribute , $value , $parameters ) : bool
Validate that an attribute matches a date format.
Parameters
- $attribute string
- $value mixed
-
$parameters
array
|string>
validateDateEquals ( $attribute , $value , $parameters ) : bool
Validate that an attribute is equal to another date.
Parameters
- $attribute string
- $value mixed
-
$parameters
array
|string>
validateDecimal ( $attribute , $value , $parameters ) : bool
Validate that an attribute has a given number of decimal places.
Parameters
- $attribute string
- $value mixed
-
$parameters
array
|string>
validateDifferent ( $attribute , $value , $parameters ) : bool
Validate that an attribute is different from another attribute.
Parameters
- $attribute string
- $value mixed
-
$parameters
array
|string>
validateDigits ( $attribute , $value , $parameters ) : bool
Validate that an attribute has a given number of digits.
Parameters
- $attribute string
- $value mixed
-
$parameters
array
|string>
validateDigitsBetween ( $attribute , $value , $parameters ) : bool
Validate that an attribute is between a given number of digits.
Parameters
- $attribute string
- $value mixed
-
$parameters
array
|string>
validateDimensions ( $attribute , $value , $parameters ) : bool
Validate the dimensions of an image matches the given values.
Parameters
- $attribute string
- $value mixed
-
$parameters
array
|string>
failsBasicDimensionChecks ( $parameters , $width , $height ) : bool
Test if the given width and height fail any conditions.
Parameters
-
$parameters
array
- $width int
- $height int
failsRatioCheck ( $parameters , $width , $height ) : bool
Determine if the given parameters fail a dimension ratio check.
Parameters
-
$parameters
array
- $width int
- $height int
validateDistinct ( $attribute , $value , $parameters ) : bool
Validate an attribute is unique among other values.
Parameters
- $attribute string
- $value mixed
-
$parameters
array
|string>
getDistinctValues ( $attribute ) : array
Get the values to distinct between.
Parameters
- $attribute string
extractDistinctValues ( $attribute ) : array
Extract the distinct values from the data.
Parameters
- $attribute string
validateEmail ( $attribute , $value , $parameters ) : bool
Validate that an attribute is a valid e-mail address.
Parameters
- $attribute string
- $value mixed
-
$parameters
array
|string>
validateExists ( $attribute , $value , $parameters ) : bool
Validate the existence of an attribute value in a database table.
Parameters
- $attribute string
- $value mixed
-
$parameters
array
|string>
getExistCount ( $connection , $table , $column , $value , $parameters ) : int
Get the number of records that exist in storage.
Parameters
- $connection mixed
- $table string
- $column string
- $value mixed
-
$parameters
array
|string>
validateUnique ( $attribute , $value , $parameters ) : bool
Validate the uniqueness of an attribute value on a given database table.
Parameters
- $attribute string
- $value mixed
-
$parameters
array
|string>
getUniqueIds ( $idColumn , $parameters ) : array
Get the excluded ID column and value for the unique rule.
Parameters
- $idColumn string|null
-
$parameters
array
|string>
prepareUniqueId ( $id ) : int
Prepare the given ID for querying.
Parameters
- $id mixed
getUniqueExtra ( $parameters ) : array
Get the extra conditions for a unique rule.
Parameters
-
$parameters
array
|string>
parseTable ( $table ) : array
Parse the connection / table for the unique / exists rules.
Parameters
- $table string
getQueryColumn ( $parameters , $attribute ) : bool
Get the column name for an exists / unique query.
Parameters
-
$parameters
array
|string> - $attribute string
guessColumnForQuery ( $attribute ) : string
Guess the database column from the given attribute name.
Parameters
- $attribute string
getExtraConditions ( array $segments ) : array
Get the extra conditions for a unique / exists rule.
Parameters
- $segments array
validateFile ( $attribute , $value ) : bool
Validate the given value is a valid file.
Parameters
- $attribute string
- $value mixed
validateFilled ( $attribute , $value ) : bool
Validate the given attribute is filled if it is present.
Parameters
- $attribute string
- $value mixed
validateGt ( $attribute , $value , $parameters ) : bool
Validate that an attribute is greater than another attribute.
Parameters
- $attribute string
- $value mixed
-
$parameters
array
|string>
validateLt ( $attribute , $value , $parameters ) : bool
Validate that an attribute is less than another attribute.
Parameters
- $attribute string
- $value mixed
-
$parameters
array
|string>
validateGte ( $attribute , $value , $parameters ) : bool
Validate that an attribute is greater than or equal another attribute.
Parameters
- $attribute string
- $value mixed
-
$parameters
array
|string>
validateLte ( $attribute , $value , $parameters ) : bool
Validate that an attribute is less than or equal another attribute.
Parameters
- $attribute string
- $value mixed
-
$parameters
array
|string>
validateLowercase ( $attribute , $value , $parameters ) : bool
Validate that an attribute is lowercase.
Parameters
- $attribute string
- $value mixed
-
$parameters
array
|string>
validateUppercase ( $attribute , $value , $parameters ) : bool
Validate that an attribute is uppercase.
Parameters
- $attribute string
- $value mixed
-
$parameters
array
|string>
validateImage ( $attribute , $value ) : bool
Validate the MIME type of a file is an image MIME type.
Parameters
- $attribute string
- $value mixed
validateIn ( $attribute , $value , $parameters ) : bool
Validate an attribute is contained within a list of values.
Parameters
- $attribute string
- $value mixed
-
$parameters
array
|string>
validateInArray ( $attribute , $value , $parameters ) : bool
Validate that the values of an attribute are in another attribute.
Parameters
- $attribute string
- $value mixed
-
$parameters
array
|string>
validateInteger ( $attribute , $value ) : bool
Validate that an attribute is an integer.
Parameters
- $attribute string
- $value mixed
validateIp ( $attribute , $value ) : bool
Validate that an attribute is a valid IP.
Parameters
- $attribute string
- $value mixed
validateIpv4 ( $attribute , $value ) : bool
Validate that an attribute is a valid IPv4.
Parameters
- $attribute string
- $value mixed
validateIpv6 ( $attribute , $value ) : bool
Validate that an attribute is a valid IPv6.
Parameters
- $attribute string
- $value mixed
validateMacAddress ( $attribute , $value ) : bool
Validate that an attribute is a valid MAC address.
Parameters
- $attribute string
- $value mixed
validateJson ( $attribute , $value ) : bool
Validate the attribute is a valid JSON string.
Parameters
- $attribute string
- $value mixed
validateMax ( $attribute , $value , $parameters ) : bool
Validate the size of an attribute is less than a maximum value.
Parameters
- $attribute string
- $value mixed
-
$parameters
array
|string>
validateMaxDigits ( $attribute , $value , $parameters ) : bool
Validate that an attribute has a maximum number of digits.
Parameters
- $attribute string
- $value mixed
-
$parameters
array
|string>
validateMimes ( $attribute , $value , $parameters ) : bool
Validate the guessed extension of a file upload is in a set of file extensions.
Parameters
- $attribute string
- $value mixed
-
$parameters
array
|string>
validateMimetypes ( $attribute , $value , $parameters ) : bool
Validate the MIME type of a file upload attribute is in a set of MIME types.
Parameters
- $attribute string
- $value mixed
-
$parameters
array
|string>
shouldBlockPhpUpload ( $value , $parameters ) : bool
Check if PHP uploads are explicitly allowed.
Parameters
- $value mixed
-
$parameters
array
|string>
validateMin ( $attribute , $value , $parameters ) : bool
Validate the size of an attribute is greater than a minimum value.
Parameters
- $attribute string
- $value mixed
-
$parameters
array
|string>
validateMinDigits ( $attribute , $value , $parameters ) : bool
Validate that an attribute has a minimum number of digits.
Parameters
- $attribute string
- $value mixed
-
$parameters
array
|string>
validateMissing ( $attribute , $value , $parameters ) : bool
Validate that an attribute is missing.
Parameters
- $attribute string
- $value mixed
-
$parameters
array
|string>
validateMissingIf ( $attribute , $value , $parameters ) : bool
Validate that an attribute is missing when another attribute has a given value.
Parameters
- $attribute string
- $value mixed
-
$parameters
array
|string>
validateMissingUnless ( $attribute , $value , $parameters ) : bool
Validate that an attribute is missing unless another attribute has a given value.
Parameters
- $attribute string
- $value mixed
-
$parameters
array
|string>
validateMissingWith ( $attribute , $value , $parameters ) : bool
Validate that an attribute is missing when any given attribute is present.
Parameters
- $attribute string
- $value mixed
-
$parameters
array
|string>
validateMissingWithAll ( $attribute , $value , $parameters ) : bool
Validate that an attribute is missing when all given attributes are present.
Parameters
- $attribute string
- $value mixed
-
$parameters
array
|string>
validateMultipleOf ( $attribute , $value , $parameters ) : bool
Validate the value of an attribute is a multiple of a given value.
Parameters
- $attribute string
- $value mixed
-
$parameters
array
|string>
validateNullable ( ) : bool
"Indicate" validation should pass if value is null.
validateNotIn ( $attribute , $value , $parameters ) : bool
Validate an attribute is not contained within a list of values.
Parameters
- $attribute string
- $value mixed
-
$parameters
array
|string>
validateNumeric ( $attribute , $value ) : bool
Validate that an attribute is numeric.
Parameters
- $attribute string
- $value mixed
validatePresent ( $attribute , $value ) : bool
Validate that an attribute exists even if not filled.
Parameters
- $attribute string
- $value mixed
validateRegex ( $attribute , $value , $parameters ) : bool
Validate that an attribute passes a regular expression check.
Parameters
- $attribute string
- $value mixed
-
$parameters
array
|string>
validateNotRegex ( $attribute , $value , $parameters ) : bool
Validate that an attribute does not pass a regular expression check.
Parameters
- $attribute string
- $value mixed
-
$parameters
array
|string>
validateRequired ( $attribute , $value ) : bool
Validate that a required attribute exists.
Parameters
- $attribute string
- $value mixed
validateRequiredIf ( $attribute , $value , $parameters ) : bool
Validate that an attribute exists when another attribute has a given value.
Parameters
- $attribute string
- $value mixed
- $parameters mixed
validateRequiredIfAccepted ( $attribute , $value , $parameters ) : bool
Validate that an attribute exists when another attribute was "accepted".
Parameters
- $attribute string
- $value mixed
- $parameters mixed
validateProhibited ( $attribute , $value ) : bool
Validate that an attribute does not exist or is an empty string.
Parameters
- $attribute string
- $value mixed
validateProhibitedIf ( $attribute , $value , $parameters ) : bool
Validate that an attribute does not exist when another attribute has a given value.
Parameters
- $attribute string
- $value mixed
- $parameters mixed
validateProhibitedUnless ( $attribute , $value , $parameters ) : bool
Validate that an attribute does not exist unless another attribute has a given value.
Parameters
- $attribute string
- $value mixed
- $parameters mixed
validateProhibits ( $attribute , $value , $parameters ) : bool
Validate that other attributes do not exist when this attribute exists.
Parameters
- $attribute string
- $value mixed
- $parameters mixed
validateExclude ( ) : bool
Indicate that an attribute is excluded.
validateExcludeIf ( $attribute , $value , $parameters ) : bool
Indicate that an attribute should be excluded when another attribute has a given value.
Parameters
- $attribute string
- $value mixed
- $parameters mixed
validateExcludeUnless ( $attribute , $value , $parameters ) : bool
Indicate that an attribute should be excluded when another attribute does not have a given value.
Parameters
- $attribute string
- $value mixed
- $parameters mixed
validateRequiredUnless ( $attribute , $value , $parameters ) : bool
Validate that an attribute exists when another attribute does not have a given value.
Parameters
- $attribute string
- $value mixed
- $parameters mixed
validateExcludeWith ( $attribute , $value , $parameters ) : bool
Indicate that an attribute should be excluded when another attribute presents.
Parameters
- $attribute string
- $value mixed
- $parameters mixed
validateExcludeWithout ( $attribute , $value , $parameters ) : bool
Indicate that an attribute should be excluded when another attribute is missing.
Parameters
- $attribute string
- $value mixed
- $parameters mixed
parseDependentRuleParameters ( $parameters ) : array
Prepare the values and the other value for validation.
Parameters
-
$parameters
array
|string>
shouldConvertToBoolean ( $parameter ) : bool
Check if parameter should be converted to boolean.
Parameters
- $parameter string
convertValuesToBoolean ( $values ) : array
Convert the given values to boolean if they are string "true" / "false".
Parameters
- $values array
convertValuesToNull ( $values ) : array
Convert the given values to null if they are string "null".
Parameters
- $values array
validateRequiredWith ( $attribute , $value , $parameters ) : bool
Validate that an attribute exists when any other attribute exists.
Parameters
- $attribute string
- $value mixed
- $parameters mixed
validateRequiredWithAll ( $attribute , $value , $parameters ) : bool
Validate that an attribute exists when all other attributes exist.
Parameters
- $attribute string
- $value mixed
- $parameters mixed
validateRequiredWithout ( $attribute , $value , $parameters ) : bool
Validate that an attribute exists when another attribute does not.
Parameters
- $attribute string
- $value mixed
- $parameters mixed
validateRequiredWithoutAll ( $attribute , $value , $parameters ) : bool
Validate that an attribute exists when all other attributes do not.
Parameters
- $attribute string
- $value mixed
- $parameters mixed
anyFailingRequired ( array $attributes ) : bool
Determine if any of the given attributes fail the required test.
Parameters
- $attributes array
allFailingRequired ( array $attributes ) : bool
Determine if all of the given attributes fail the required test.
Parameters
- $attributes array
validateSame ( $attribute , $value , $parameters ) : bool
Validate that two attributes match.
Parameters
- $attribute string
- $value mixed
-
$parameters
array
|string>
validateSize ( $attribute , $value , $parameters ) : bool
Validate the size of an attribute.
Parameters
- $attribute string
- $value mixed
-
$parameters
array
|string>
validateSometimes ( ) : bool
"Validate" optional attributes.
validateStartsWith ( $attribute , $value , $parameters ) : bool
Validate the attribute starts with a given substring.
Parameters
- $attribute string
- $value mixed
-
$parameters
array
|string>
validateDoesntStartWith ( $attribute , $value , $parameters ) : bool
Validate the attribute does not start with a given substring.
Parameters
- $attribute string
- $value mixed
-
$parameters
array
|string>
validateEndsWith ( $attribute , $value , $parameters ) : bool
Validate the attribute ends with a given substring.
Parameters
- $attribute string
- $value mixed
-
$parameters
array
|string>
validateDoesntEndWith ( $attribute , $value , $parameters ) : bool
Validate the attribute does not end with a given substring.
Parameters
- $attribute string
- $value mixed
-
$parameters
array
|string>
validateString ( $attribute , $value ) : bool
Validate that an attribute is a string.
Parameters
- $attribute string
- $value mixed
validateTimezone ( $attribute , $value , $parameters ) : bool
Validate that an attribute is a valid timezone.
Parameters
- $attribute string
- $value mixed
-
$parameters
array
|string>
validateUrl ( $attribute , $value , $parameters ) : bool
Validate that an attribute is a valid URL.
Parameters
- $attribute string
- $value mixed
-
$parameters
array
validateUlid ( $attribute , $value ) : bool
Validate that an attribute is a valid ULID.
Parameters
- $attribute string
- $value mixed
validateUuid ( $attribute , $value ) : bool
Validate that an attribute is a valid UUID.
Parameters
- $attribute string
- $value mixed
getSize ( $attribute , $value ) : int|float|string
Get the size of an attribute.
Parameters
- $attribute string
- $value mixed
isValidFileInstance ( $value ) : bool
Check that the given value is a valid file instance.
Parameters
- $value mixed
compare ( $first , $second , $operator ) : bool
Determine if a comparison passes between the given values.
Parameters
- $first mixed
- $second mixed
- $operator string
parseNamedParameters ( $parameters ) : array
Parse named parameters to $key => $value items.
Parameters
-
$parameters
array
|string>
requireParameterCount ( $count , $parameters , $rule ) : void
Require a certain number of parameters to be present.
Parameters
- $count int
-
$parameters
array
|string> - $rule string
isSameType ( $first , $second ) : bool
Check if the parameters are of the same type.
Parameters
- $first mixed
- $second mixed
shouldBeNumeric ( $attribute , $rule ) : void
Adds the existing rule to the numericRules array if the attribute's value is numeric.
Parameters
- $attribute string
- $rule string
trim ( $value ) : mixed
Trim the value if it is a string.
Parameters
- $value mixed
ensureExponentWithinAllowedRange ( $attribute , $value ) : mixed
Ensure the exponent is within the allowed range.
Parameters
- $attribute string
- $value mixed