trait Illuminate / Validation / Concerns / ValidatesAttributes
You are viewing an older version of the documentation. For the latest, please visit master documentation.

ValidatesAttributes

Methods

public

validateAccepted ( $attribute , $value ) : bool

Validate that an attribute was "accepted".

Parameters

  • $attribute string
  • $value mixed
public

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
public

validateDeclined ( $attribute , $value ) : bool

Validate that an attribute was "declined".

Parameters

  • $attribute string
  • $value mixed
public

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
public

validateActiveUrl ( $attribute , $value ) : bool

Validate that an attribute is an active URL.

Parameters

  • $attribute string
  • $value mixed
public

validateBail ( ) : bool

"Break" on first validation fail.

public

validateBefore ( $attribute , $value , $parameters ) : bool

Validate the date is before a given date.

Parameters

  • $attribute string
  • $value mixed
  • $parameters array
public

validateBeforeOrEqual ( $attribute , $value , $parameters ) : bool

Validate the date is before or equal a given date.

Parameters

  • $attribute string
  • $value mixed
  • $parameters array
public

validateAfter ( $attribute , $value , $parameters ) : bool

Validate the date is after a given date.

Parameters

  • $attribute string
  • $value mixed
  • $parameters array
public

validateAfterOrEqual ( $attribute , $value , $parameters ) : bool

Validate the date is equal or after a given date.

Parameters

  • $attribute string
  • $value mixed
  • $parameters array
protected

compareDates ( $attribute , $value , $parameters , $operator ) : bool

Compare a given date against another using an operator.

Parameters

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

getDateFormat ( $attribute ) : string|null

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

Parameters

  • $attribute string
protected

getDateTimestamp ( $value ) : int

Get the date timestamp.

Parameters

  • $value mixed
protected

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
protected

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

Get a DateTime instance from a string.

Parameters

  • $format string
  • $value string
protected

getDateTime ( $value ) : DateTime |null

Get a DateTime instance from a string with no format.

Parameters

  • $value string
public

validateAlpha ( $attribute , $value ) : bool

Validate that an attribute contains only alphabetic characters.

Parameters

  • $attribute string
  • $value mixed
public

validateAlphaDash ( $attribute , $value ) : bool

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

Parameters

  • $attribute string
  • $value mixed
public

validateAlphaNum ( $attribute , $value ) : bool

Validate that an attribute contains only alpha-numeric characters.

Parameters

  • $attribute string
  • $value mixed
public

validateArray ( $attribute , $value , $parameters ) : bool

Validate that an attribute is an array.

Parameters

  • $attribute string
  • $value mixed
  • $parameters array
public

validateRequiredArrayKeys ( $attribute , $value , $parameters ) : bool

Validate that an array has all of the given keys.

Parameters

  • $attribute string
  • $value mixed
  • $parameters array
public

validateBetween ( $attribute , $value , $parameters ) : bool

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

Parameters

  • $attribute string
  • $value mixed
  • $parameters array
public

validateBoolean ( $attribute , $value ) : bool

Validate that an attribute is a boolean.

Parameters

  • $attribute string
  • $value mixed
public

validateConfirmed ( $attribute , $value ) : bool

Validate that an attribute has a matching confirmation.

Parameters

  • $attribute string
  • $value mixed
protected

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
public

validateDate ( $attribute , $value ) : bool

Validate that an attribute is a valid date.

Parameters

  • $attribute string
  • $value mixed
public

validateDateFormat ( $attribute , $value , $parameters ) : bool

Validate that an attribute matches a date format.

Parameters

  • $attribute string
  • $value mixed
  • $parameters array
public

validateDateEquals ( $attribute , $value , $parameters ) : bool

Validate that an attribute is equal to another date.

Parameters

  • $attribute string
  • $value mixed
  • $parameters array
public

validateDifferent ( $attribute , $value , $parameters ) : bool

Validate that an attribute is different from another attribute.

Parameters

  • $attribute string
  • $value mixed
  • $parameters array
public

validateDigits ( $attribute , $value , $parameters ) : bool

Validate that an attribute has a given number of digits.

Parameters

  • $attribute string
  • $value mixed
  • $parameters array
public

validateDigitsBetween ( $attribute , $value , $parameters ) : bool

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

Parameters

  • $attribute string
  • $value mixed
  • $parameters array
public

validateDimensions ( $attribute , $value , $parameters ) : bool

Validate the dimensions of an image matches the given values.

Parameters

  • $attribute string
  • $value mixed
  • $parameters array
protected

failsBasicDimensionChecks ( $parameters , $width , $height ) : bool

Test if the given width and height fail any conditions.

Parameters

  • $parameters array
  • $width int
  • $height int
protected

failsRatioCheck ( $parameters , $width , $height ) : bool

Determine if the given parameters fail a dimension ratio check.

Parameters

  • $parameters array
  • $width int
  • $height int
public

validateDistinct ( $attribute , $value , $parameters ) : bool

Validate an attribute is unique among other values.

Parameters

  • $attribute string
  • $value mixed
  • $parameters array
protected

getDistinctValues ( $attribute ) : array

Get the values to distinct between.

Parameters

  • $attribute string
protected

extractDistinctValues ( $attribute ) : array

Extract the distinct values from the data.

Parameters

  • $attribute string
public

validateEmail ( $attribute , $value , $parameters ) : bool

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

Parameters

  • $attribute string
  • $value mixed
  • $parameters array
public

validateExists ( $attribute , $value , $parameters ) : bool

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

Parameters

  • $attribute string
  • $value mixed
  • $parameters array
protected

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
public

validateUnique ( $attribute , $value , $parameters ) : bool

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

Parameters

  • $attribute string
  • $value mixed
  • $parameters array
protected

getUniqueIds ( $idColumn , $parameters ) : array

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

Parameters

  • $idColumn string|null
  • $parameters array
protected

prepareUniqueId ( $id ) : int

Prepare the given ID for querying.

Parameters

  • $id mixed
protected

getUniqueExtra ( $parameters ) : array

Get the extra conditions for a unique rule.

Parameters

  • $parameters array
public

parseTable ( $table ) : array

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

Parameters

  • $table string
public

getQueryColumn ( $parameters , $attribute ) : bool

Get the column name for an exists / unique query.

Parameters

  • $parameters array
  • $attribute string
public

guessColumnForQuery ( $attribute ) : string

Guess the database column from the given attribute name.

Parameters

  • $attribute string
protected

getExtraConditions ( array $segments ) : array

Get the extra conditions for a unique / exists rule.

Parameters

  • $segments array
public

validateFile ( $attribute , $value ) : bool

Validate the given value is a valid file.

Parameters

  • $attribute string
  • $value mixed
public

validateFilled ( $attribute , $value ) : bool

Validate the given attribute is filled if it is present.

Parameters

  • $attribute string
  • $value mixed
public

validateGt ( $attribute , $value , $parameters ) : bool

Validate that an attribute is greater than another attribute.

Parameters

  • $attribute string
  • $value mixed
  • $parameters array
public

validateLt ( $attribute , $value , $parameters ) : bool

Validate that an attribute is less than another attribute.

Parameters

  • $attribute string
  • $value mixed
  • $parameters array
public

validateGte ( $attribute , $value , $parameters ) : bool

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

Parameters

  • $attribute string
  • $value mixed
  • $parameters array
public

validateLte ( $attribute , $value , $parameters ) : bool

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

Parameters

  • $attribute string
  • $value mixed
  • $parameters array
public

validateImage ( $attribute , $value ) : bool

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

Parameters

  • $attribute string
  • $value mixed
public

validateIn ( $attribute , $value , $parameters ) : bool

Validate an attribute is contained within a list of values.

Parameters

  • $attribute string
  • $value mixed
  • $parameters array
public

validateInArray ( $attribute , $value , $parameters ) : bool

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

Parameters

  • $attribute string
  • $value mixed
  • $parameters array
public

validateInteger ( $attribute , $value ) : bool

Validate that an attribute is an integer.

Parameters

  • $attribute string
  • $value mixed
public

validateIp ( $attribute , $value ) : bool

Validate that an attribute is a valid IP.

Parameters

  • $attribute string
  • $value mixed
public

validateIpv4 ( $attribute , $value ) : bool

Validate that an attribute is a valid IPv4.

Parameters

  • $attribute string
  • $value mixed
public

validateIpv6 ( $attribute , $value ) : bool

Validate that an attribute is a valid IPv6.

Parameters

  • $attribute string
  • $value mixed
public

validateMacAddress ( $attribute , $value ) : bool

Validate that an attribute is a valid MAC address.

Parameters

  • $attribute string
  • $value mixed
public

validateJson ( $attribute , $value ) : bool

Validate the attribute is a valid JSON string.

Parameters

  • $attribute string
  • $value mixed
public

validateMax ( $attribute , $value , $parameters ) : bool

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

Parameters

  • $attribute string
  • $value mixed
  • $parameters array
public

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
public

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
protected

shouldBlockPhpUpload ( $value , $parameters ) : bool

Check if PHP uploads are explicitly allowed.

Parameters

  • $value mixed
  • $parameters array
public

validateMin ( $attribute , $value , $parameters ) : bool

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

Parameters

  • $attribute string
  • $value mixed
  • $parameters array
public

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
public

validateNullable ( ) : bool

"Indicate" validation should pass if value is null.

public

validateNotIn ( $attribute , $value , $parameters ) : bool

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

Parameters

  • $attribute string
  • $value mixed
  • $parameters array
public

validateNumeric ( $attribute , $value ) : bool

Validate that an attribute is numeric.

Parameters

  • $attribute string
  • $value mixed
protected

validatePassword ( $attribute , $value , $parameters ) : bool

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

Parameters

  • $attribute string
  • $value mixed
  • $parameters array
public

validatePresent ( $attribute , $value ) : bool

Validate that an attribute exists even if not filled.

Parameters

  • $attribute string
  • $value mixed
public

validateRegex ( $attribute , $value , $parameters ) : bool

Validate that an attribute passes a regular expression check.

Parameters

  • $attribute string
  • $value mixed
  • $parameters array
public

validateNotRegex ( $attribute , $value , $parameters ) : bool

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

Parameters

  • $attribute string
  • $value mixed
  • $parameters array
public

validateRequired ( $attribute , $value ) : bool

Validate that a required attribute exists.

Parameters

  • $attribute string
  • $value mixed
public

validateRequiredIf ( $attribute , $value , $parameters ) : bool

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

Parameters

  • $attribute string
  • $value mixed
  • $parameters mixed
public

validateProhibited ( $attribute , $value ) : bool

Validate that an attribute does not exist.

Parameters

  • $attribute string
  • $value mixed
  • $parameters mixed
public

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
public

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
public

validateProhibits ( $attribute , $value , $parameters ) : bool

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

Parameters

  • $attribute string
  • $value mixed
  • $parameters mixed
public

validateExclude ( ) : bool

Indicate that an attribute is excluded.

public

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
public

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
public

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
public

validateExcludeWithout ( $attribute , $value , $parameters ) : bool

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

Parameters

  • $attribute string
  • $value mixed
  • $parameters mixed
public

parseDependentRuleParameters ( $parameters ) : array

Prepare the values and the other value for validation.

Parameters

  • $parameters array
protected

shouldConvertToBoolean ( $parameter ) : bool

Check if parameter should be converted to boolean.

Parameters

  • $parameter string
protected

convertValuesToBoolean ( $values ) : array

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

Parameters

  • $values array
protected

convertValuesToNull ( $values ) : array

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

Parameters

  • $values array
public

validateRequiredWith ( $attribute , $value , $parameters ) : bool

Validate that an attribute exists when any other attribute exists.

Parameters

  • $attribute string
  • $value mixed
  • $parameters mixed
public

validateRequiredWithAll ( $attribute , $value , $parameters ) : bool

Validate that an attribute exists when all other attributes exist.

Parameters

  • $attribute string
  • $value mixed
  • $parameters mixed
public

validateRequiredWithout ( $attribute , $value , $parameters ) : bool

Validate that an attribute exists when another attribute does not.

Parameters

  • $attribute string
  • $value mixed
  • $parameters mixed
public

validateRequiredWithoutAll ( $attribute , $value , $parameters ) : bool

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

Parameters

  • $attribute string
  • $value mixed
  • $parameters mixed
protected

anyFailingRequired ( array $attributes ) : bool

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

Parameters

  • $attributes array
protected

allFailingRequired ( array $attributes ) : bool

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

Parameters

  • $attributes array
public

validateSame ( $attribute , $value , $parameters ) : bool

Validate that two attributes match.

Parameters

  • $attribute string
  • $value mixed
  • $parameters array
public

validateSize ( $attribute , $value , $parameters ) : bool

Validate the size of an attribute.

Parameters

  • $attribute string
  • $value mixed
  • $parameters array
public

validateSometimes ( ) : bool

"Validate" optional attributes.

public

validateStartsWith ( $attribute , $value , $parameters ) : bool

Validate the attribute starts with a given substring.

Parameters

  • $attribute string
  • $value mixed
  • $parameters array
public

validateEndsWith ( $attribute , $value , $parameters ) : bool

Validate the attribute ends with a given substring.

Parameters

  • $attribute string
  • $value mixed
  • $parameters array
public

validateString ( $attribute , $value ) : bool

Validate that an attribute is a string.

Parameters

  • $attribute string
  • $value mixed
public

validateTimezone ( $attribute , $value ) : bool

Validate that an attribute is a valid timezone.

Parameters

  • $attribute string
  • $value mixed
public

validateUrl ( $attribute , $value ) : bool

Validate that an attribute is a valid URL.

Parameters

  • $attribute string
  • $value mixed
public

validateUuid ( $attribute , $value ) : bool

Validate that an attribute is a valid UUID.

Parameters

  • $attribute string
  • $value mixed
protected

getSize ( $attribute , $value ) : mixed

Get the size of an attribute.

Parameters

  • $attribute string
  • $value mixed
public

isValidFileInstance ( $value ) : bool

Check that the given value is a valid file instance.

Parameters

  • $value mixed
protected

compare ( $first , $second , $operator ) : bool

Determine if a comparison passes between the given values.

Parameters

  • $first mixed
  • $second mixed
  • $operator string
public

parseNamedParameters ( $parameters ) : array

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

Parameters

  • $parameters array
public

requireParameterCount ( $count , $parameters , $rule ) : void

Require a certain number of parameters to be present.

Parameters

  • $count int
  • $parameters array
  • $rule string
protected

isSameType ( $first , $second ) : bool

Check if the parameters are of the same type.

Parameters

  • $first mixed
  • $second mixed
protected

shouldBeNumeric ( $attribute , $rule ) : void

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

Parameters

  • $attribute string
  • $rule string