ValidatesAttributes
Table of Contents
- guessColumnForQuery() : string
- Guess the database column from the given attribute name.
- isValidFileInstance() : bool
- Check that the given value is a valid file instance.
- validateAccepted() : bool
- Validate that an attribute was "accepted".
- validateActiveUrl() : bool
- Validate that an attribute is an active URL.
- validateAfter() : bool
- Validate the date is after a given date.
- validateAfterOrEqual() : bool
- Validate the date is equal or after a given date.
- validateAlpha() : bool
- Validate that an attribute contains only alphabetic characters.
- validateAlphaDash() : bool
- Validate that an attribute contains only alpha-numeric characters, dashes, and underscores.
- validateAlphaNum() : bool
- Validate that an attribute contains only alpha-numeric characters.
- validateArray() : bool
- Validate that an attribute is an array.
- validateBail() : bool
- "Break" on first validation fail.
- validateBefore() : bool
- Validate the date is before a given date.
- validateBeforeOrEqual() : bool
- Validate the date is before or equal a given date.
- validateBetween() : bool
- Validate the size of an attribute is between a set of values.
- validateBoolean() : bool
- Validate that an attribute is a boolean.
- validateConfirmed() : bool
- Validate that an attribute has a matching confirmation.
- validateDate() : bool
- Validate that an attribute is a valid date.
- validateDateEquals() : bool
- Validate that an attribute is equal to another date.
- validateDateFormat() : bool
- Validate that an attribute matches a date format.
- validateDifferent() : bool
- Validate that an attribute is different from another attribute.
- validateDigits() : bool
- Validate that an attribute has a given number of digits.
- validateDigitsBetween() : bool
- Validate that an attribute is between a given number of digits.
- validateDimensions() : bool
- Validate the dimensions of an image matches the given values.
- validateDistinct() : bool
- Validate an attribute is unique among other values.
- validateEmail() : bool
- Validate that an attribute is a valid e-mail address.
- validateExists() : bool
- Validate the existence of an attribute value in a database table.
- validateFile() : bool
- Validate the given value is a valid file.
- validateFilled() : bool
- Validate the given attribute is filled if it is present.
- validateImage() : bool
- Validate the MIME type of a file is an image MIME type.
- validateIn() : bool
- Validate an attribute is contained within a list of values.
- validateInArray() : bool
- Validate that the values of an attribute is in another attribute.
- validateInteger() : bool
- Validate that an attribute is an integer.
- validateIp() : bool
- Validate that an attribute is a valid IP.
- validateIpv4() : bool
- Validate that an attribute is a valid IPv4.
- validateIpv6() : bool
- Validate that an attribute is a valid IPv6.
- validateJson() : bool
- Validate the attribute is a valid JSON string.
- validateMax() : bool
- Validate the size of an attribute is less than a maximum value.
- validateMimes() : bool
- Validate the guessed extension of a file upload is in a set of file extensions.
- validateMimetypes() : bool
- Validate the MIME type of a file upload attribute is in a set of MIME types.
- validateMin() : bool
- Validate the size of an attribute is greater than a minimum value.
- validateNotIn() : bool
- Validate an attribute is not contained within a list of values.
- validateNullable() : bool
- "Indicate" validation should pass if value is null.
- validateNumeric() : bool
- Validate that an attribute is numeric.
- validatePresent() : bool
- Validate that an attribute exists even if not filled.
- validateRegex() : bool
- Validate that an attribute passes a regular expression check.
- validateRequired() : bool
- Validate that a required attribute exists.
- validateRequiredIf() : bool
- Validate that an attribute exists when another attribute has a given value.
- validateRequiredUnless() : bool
- Validate that an attribute exists when another attribute does not have a given value.
- validateRequiredWith() : bool
- Validate that an attribute exists when any other attribute exists.
- validateRequiredWithAll() : bool
- Validate that an attribute exists when all other attributes exists.
- validateRequiredWithout() : bool
- Validate that an attribute exists when another attribute does not.
- validateRequiredWithoutAll() : bool
- Validate that an attribute exists when all other attributes do not.
- validateSame() : bool
- Validate that two attributes match.
- validateSize() : bool
- Validate the size of an attribute.
- validateSometimes() : bool
- "Validate" optional attributes.
- validateString() : bool
- Validate that an attribute is a string.
- validateTimezone() : bool
- Validate that an attribute is a valid timezone.
- validateUnique() : bool
- Validate the uniqueness of an attribute value on a given database table.
- validateUrl() : bool
- Validate that an attribute is a valid URL.
- allFailingRequired() : bool
- Determine if all of the given attributes fail the required test.
- anyFailingRequired() : bool
- Determine if any of the given attributes fail the required test.
- checkDateTimeOrder() : bool
- Given two date/time strings, check that one is after the other.
- compare() : bool
- Determine if a comparison passes between the given values.
- compareDates() : bool
- Compare a given date against another using an operator.
- convertValuesToBoolean() : array<string|int, mixed>
- Convert the given values to boolean if they are string "true" / "false".
- failsBasicDimensionChecks() : bool
- Test if the given width and height fail any conditions.
- failsRatioCheck() : bool
- Determine if the given parameters fail a dimension ratio check.
- getDateFormat() : string|null
- Get the date format for an attribute if it has one.
- getDateTimestamp() : int
- Get the date timestamp.
- getDateTimeWithOptionalFormat() : DateTime|null
- Get a DateTime instance from a string.
- getExistCount() : int
- Get the number of records that exist in storage.
- getExtraConditions() : array<string|int, mixed>
- Get the extra conditions for a unique / exists rule.
- getQueryColumn() : bool
- Get the column name for an exists / unique query.
- getSize() : mixed
- Get the size of an attribute.
- getUniqueExtra() : array<string|int, mixed>
- Get the extra conditions for a unique rule.
- getUniqueIds() : array<string|int, mixed>
- Get the excluded ID column and value for the unique rule.
- parseNamedParameters() : array<string|int, mixed>
- Parse named parameters to $key => $value items.
- parseTable() : array<string|int, mixed>
- Parse the connection / table for the unique / exists rules.
- prepareUniqueId() : int
- Prepare the given ID for querying.
- requireParameterCount() : void
- Require a certain number of parameters to be present.
- shouldBlockPhpUpload() : bool
- Check if PHP uploads are explicitly allowed.
Methods
guessColumnForQuery()
Guess the database column from the given attribute name.
public
guessColumnForQuery(string $attribute) : string
Parameters
- $attribute : string
Return values
string —isValidFileInstance()
Check that the given value is a valid file instance.
public
isValidFileInstance(mixed $value) : bool
Parameters
- $value : mixed
Return values
bool —validateAccepted()
Validate that an attribute was "accepted".
public
validateAccepted(string $attribute, mixed $value) : bool
This validation rule implies the attribute is "required".
Parameters
- $attribute : string
- $value : mixed
Return values
bool —validateActiveUrl()
Validate that an attribute is an active URL.
public
validateActiveUrl(string $attribute, mixed $value) : bool
Parameters
- $attribute : string
- $value : mixed
Return values
bool —validateAfter()
Validate the date is after a given date.
public
validateAfter(string $attribute, mixed $value, array<string|int, mixed> $parameters) : bool
Parameters
- $attribute : string
- $value : mixed
- $parameters : array<string|int, mixed>
Return values
bool —validateAfterOrEqual()
Validate the date is equal or after a given date.
public
validateAfterOrEqual(string $attribute, mixed $value, array<string|int, mixed> $parameters) : bool
Parameters
- $attribute : string
- $value : mixed
- $parameters : array<string|int, mixed>
Return values
bool —validateAlpha()
Validate that an attribute contains only alphabetic characters.
public
validateAlpha(string $attribute, mixed $value) : bool
Parameters
- $attribute : string
- $value : mixed
Return values
bool —validateAlphaDash()
Validate that an attribute contains only alpha-numeric characters, dashes, and underscores.
public
validateAlphaDash(string $attribute, mixed $value) : bool
Parameters
- $attribute : string
- $value : mixed
Return values
bool —validateAlphaNum()
Validate that an attribute contains only alpha-numeric characters.
public
validateAlphaNum(string $attribute, mixed $value) : bool
Parameters
- $attribute : string
- $value : mixed
Return values
bool —validateArray()
Validate that an attribute is an array.
public
validateArray(string $attribute, mixed $value) : bool
Parameters
- $attribute : string
- $value : mixed
Return values
bool —validateBail()
"Break" on first validation fail.
public
validateBail() : bool
Always returns true, just lets us put "bail" in rules.
Return values
bool —validateBefore()
Validate the date is before a given date.
public
validateBefore(string $attribute, mixed $value, array<string|int, mixed> $parameters) : bool
Parameters
- $attribute : string
- $value : mixed
- $parameters : array<string|int, mixed>
Return values
bool —validateBeforeOrEqual()
Validate the date is before or equal a given date.
public
validateBeforeOrEqual(string $attribute, mixed $value, array<string|int, mixed> $parameters) : bool
Parameters
- $attribute : string
- $value : mixed
- $parameters : array<string|int, mixed>
Return values
bool —validateBetween()
Validate the size of an attribute is between a set of values.
public
validateBetween(string $attribute, mixed $value, array<string|int, mixed> $parameters) : bool
Parameters
- $attribute : string
- $value : mixed
- $parameters : array<string|int, mixed>
Return values
bool —validateBoolean()
Validate that an attribute is a boolean.
public
validateBoolean(string $attribute, mixed $value) : bool
Parameters
- $attribute : string
- $value : mixed
Return values
bool —validateConfirmed()
Validate that an attribute has a matching confirmation.
public
validateConfirmed(string $attribute, mixed $value) : bool
Parameters
- $attribute : string
- $value : mixed
Return values
bool —validateDate()
Validate that an attribute is a valid date.
public
validateDate(string $attribute, mixed $value) : bool
Parameters
- $attribute : string
- $value : mixed
Return values
bool —validateDateEquals()
Validate that an attribute is equal to another date.
public
validateDateEquals(string $attribute, mixed $value, array<string|int, mixed> $parameters) : bool
Parameters
- $attribute : string
- $value : mixed
- $parameters : array<string|int, mixed>
Return values
bool —validateDateFormat()
Validate that an attribute matches a date format.
public
validateDateFormat(string $attribute, mixed $value, array<string|int, mixed> $parameters) : bool
Parameters
- $attribute : string
- $value : mixed
- $parameters : array<string|int, mixed>
Return values
bool —validateDifferent()
Validate that an attribute is different from another attribute.
public
validateDifferent(string $attribute, mixed $value, array<string|int, mixed> $parameters) : bool
Parameters
- $attribute : string
- $value : mixed
- $parameters : array<string|int, mixed>
Return values
bool —validateDigits()
Validate that an attribute has a given number of digits.
public
validateDigits(string $attribute, mixed $value, array<string|int, mixed> $parameters) : bool
Parameters
- $attribute : string
- $value : mixed
- $parameters : array<string|int, mixed>
Return values
bool —validateDigitsBetween()
Validate that an attribute is between a given number of digits.
public
validateDigitsBetween(string $attribute, mixed $value, array<string|int, mixed> $parameters) : bool
Parameters
- $attribute : string
- $value : mixed
- $parameters : array<string|int, mixed>
Return values
bool —validateDimensions()
Validate the dimensions of an image matches the given values.
public
validateDimensions(string $attribute, mixed $value, array<string|int, mixed> $parameters) : bool
Parameters
- $attribute : string
- $value : mixed
- $parameters : array<string|int, mixed>
Return values
bool —validateDistinct()
Validate an attribute is unique among other values.
public
validateDistinct(string $attribute, mixed $value, array<string|int, mixed> $parameters) : bool
Parameters
- $attribute : string
- $value : mixed
- $parameters : array<string|int, mixed>
Return values
bool —validateEmail()
Validate that an attribute is a valid e-mail address.
public
validateEmail(string $attribute, mixed $value) : bool
Parameters
- $attribute : string
- $value : mixed
Return values
bool —validateExists()
Validate the existence of an attribute value in a database table.
public
validateExists(string $attribute, mixed $value, array<string|int, mixed> $parameters) : bool
Parameters
- $attribute : string
- $value : mixed
- $parameters : array<string|int, mixed>
Return values
bool —validateFile()
Validate the given value is a valid file.
public
validateFile(string $attribute, mixed $value) : bool
Parameters
- $attribute : string
- $value : mixed
Return values
bool —validateFilled()
Validate the given attribute is filled if it is present.
public
validateFilled(string $attribute, mixed $value) : bool
Parameters
- $attribute : string
- $value : mixed
Return values
bool —validateImage()
Validate the MIME type of a file is an image MIME type.
public
validateImage(string $attribute, mixed $value) : bool
Parameters
- $attribute : string
- $value : mixed
Return values
bool —validateIn()
Validate an attribute is contained within a list of values.
public
validateIn(string $attribute, mixed $value, array<string|int, mixed> $parameters) : bool
Parameters
- $attribute : string
- $value : mixed
- $parameters : array<string|int, mixed>
Return values
bool —validateInArray()
Validate that the values of an attribute is in another attribute.
public
validateInArray(string $attribute, mixed $value, array<string|int, mixed> $parameters) : bool
Parameters
- $attribute : string
- $value : mixed
- $parameters : array<string|int, mixed>
Return values
bool —validateInteger()
Validate that an attribute is an integer.
public
validateInteger(string $attribute, mixed $value) : bool
Parameters
- $attribute : string
- $value : mixed
Return values
bool —validateIp()
Validate that an attribute is a valid IP.
public
validateIp(string $attribute, mixed $value) : bool
Parameters
- $attribute : string
- $value : mixed
Return values
bool —validateIpv4()
Validate that an attribute is a valid IPv4.
public
validateIpv4(string $attribute, mixed $value) : bool
Parameters
- $attribute : string
- $value : mixed
Return values
bool —validateIpv6()
Validate that an attribute is a valid IPv6.
public
validateIpv6(string $attribute, mixed $value) : bool
Parameters
- $attribute : string
- $value : mixed
Return values
bool —validateJson()
Validate the attribute is a valid JSON string.
public
validateJson(string $attribute, mixed $value) : bool
Parameters
- $attribute : string
- $value : mixed
Return values
bool —validateMax()
Validate the size of an attribute is less than a maximum value.
public
validateMax(string $attribute, mixed $value, array<string|int, mixed> $parameters) : bool
Parameters
- $attribute : string
- $value : mixed
- $parameters : array<string|int, mixed>
Return values
bool —validateMimes()
Validate the guessed extension of a file upload is in a set of file extensions.
public
validateMimes(string $attribute, mixed $value, array<string|int, mixed> $parameters) : bool
Parameters
- $attribute : string
- $value : mixed
- $parameters : array<string|int, mixed>
Return values
bool —validateMimetypes()
Validate the MIME type of a file upload attribute is in a set of MIME types.
public
validateMimetypes(string $attribute, mixed $value, array<string|int, mixed> $parameters) : bool
Parameters
- $attribute : string
- $value : mixed
- $parameters : array<string|int, mixed>
Return values
bool —validateMin()
Validate the size of an attribute is greater than a minimum value.
public
validateMin(string $attribute, mixed $value, array<string|int, mixed> $parameters) : bool
Parameters
- $attribute : string
- $value : mixed
- $parameters : array<string|int, mixed>
Return values
bool —validateNotIn()
Validate an attribute is not contained within a list of values.
public
validateNotIn(string $attribute, mixed $value, array<string|int, mixed> $parameters) : bool
Parameters
- $attribute : string
- $value : mixed
- $parameters : array<string|int, mixed>
Return values
bool —validateNullable()
"Indicate" validation should pass if value is null.
public
validateNullable() : bool
Always returns true, just lets us put "nullable" in rules.
Return values
bool —validateNumeric()
Validate that an attribute is numeric.
public
validateNumeric(string $attribute, mixed $value) : bool
Parameters
- $attribute : string
- $value : mixed
Return values
bool —validatePresent()
Validate that an attribute exists even if not filled.
public
validatePresent(string $attribute, mixed $value) : bool
Parameters
- $attribute : string
- $value : mixed
Return values
bool —validateRegex()
Validate that an attribute passes a regular expression check.
public
validateRegex(string $attribute, mixed $value, array<string|int, mixed> $parameters) : bool
Parameters
- $attribute : string
- $value : mixed
- $parameters : array<string|int, mixed>
Return values
bool —validateRequired()
Validate that a required attribute exists.
public
validateRequired(string $attribute, mixed $value) : bool
Parameters
- $attribute : string
- $value : mixed
Return values
bool —validateRequiredIf()
Validate that an attribute exists when another attribute has a given value.
public
validateRequiredIf(string $attribute, mixed $value, mixed $parameters) : bool
Parameters
- $attribute : string
- $value : mixed
- $parameters : mixed
Return values
bool —validateRequiredUnless()
Validate that an attribute exists when another attribute does not have a given value.
public
validateRequiredUnless(string $attribute, mixed $value, mixed $parameters) : bool
Parameters
- $attribute : string
- $value : mixed
- $parameters : mixed
Return values
bool —validateRequiredWith()
Validate that an attribute exists when any other attribute exists.
public
validateRequiredWith(string $attribute, mixed $value, mixed $parameters) : bool
Parameters
- $attribute : string
- $value : mixed
- $parameters : mixed
Return values
bool —validateRequiredWithAll()
Validate that an attribute exists when all other attributes exists.
public
validateRequiredWithAll(string $attribute, mixed $value, mixed $parameters) : bool
Parameters
- $attribute : string
- $value : mixed
- $parameters : mixed
Return values
bool —validateRequiredWithout()
Validate that an attribute exists when another attribute does not.
public
validateRequiredWithout(string $attribute, mixed $value, mixed $parameters) : bool
Parameters
- $attribute : string
- $value : mixed
- $parameters : mixed
Return values
bool —validateRequiredWithoutAll()
Validate that an attribute exists when all other attributes do not.
public
validateRequiredWithoutAll(string $attribute, mixed $value, mixed $parameters) : bool
Parameters
- $attribute : string
- $value : mixed
- $parameters : mixed
Return values
bool —validateSame()
Validate that two attributes match.
public
validateSame(string $attribute, mixed $value, array<string|int, mixed> $parameters) : bool
Parameters
- $attribute : string
- $value : mixed
- $parameters : array<string|int, mixed>
Return values
bool —validateSize()
Validate the size of an attribute.
public
validateSize(string $attribute, mixed $value, array<string|int, mixed> $parameters) : bool
Parameters
- $attribute : string
- $value : mixed
- $parameters : array<string|int, mixed>
Return values
bool —validateSometimes()
"Validate" optional attributes.
public
validateSometimes() : bool
Always returns true, just lets us put sometimes in rules.
Return values
bool —validateString()
Validate that an attribute is a string.
public
validateString(string $attribute, mixed $value) : bool
Parameters
- $attribute : string
- $value : mixed
Return values
bool —validateTimezone()
Validate that an attribute is a valid timezone.
public
validateTimezone(string $attribute, mixed $value) : bool
Parameters
- $attribute : string
- $value : mixed
Return values
bool —validateUnique()
Validate the uniqueness of an attribute value on a given database table.
public
validateUnique(string $attribute, mixed $value, array<string|int, mixed> $parameters) : bool
If a database column is not specified, the attribute will be used.
Parameters
- $attribute : string
- $value : mixed
- $parameters : array<string|int, mixed>
Return values
bool —validateUrl()
Validate that an attribute is a valid URL.
public
validateUrl(string $attribute, mixed $value) : bool
Parameters
- $attribute : string
- $value : mixed
Return values
bool —allFailingRequired()
Determine if all of the given attributes fail the required test.
protected
allFailingRequired(array<string|int, mixed> $attributes) : bool
Parameters
- $attributes : array<string|int, mixed>
Return values
bool —anyFailingRequired()
Determine if any of the given attributes fail the required test.
protected
anyFailingRequired(array<string|int, mixed> $attributes) : bool
Parameters
- $attributes : array<string|int, mixed>
Return values
bool —checkDateTimeOrder()
Given two date/time strings, check that one is after the other.
protected
checkDateTimeOrder(string $format, string $first, string $second, string $operator) : bool
Parameters
- $format : string
- $first : string
- $second : string
- $operator : string
Return values
bool —compare()
Determine if a comparison passes between the given values.
protected
compare(mixed $first, mixed $second, string $operator) : bool
Parameters
- $first : mixed
- $second : mixed
- $operator : string
Return values
bool —compareDates()
Compare a given date against another using an operator.
protected
compareDates(string $attribute, mixed $value, array<string|int, mixed> $parameters, string $operator) : bool
Parameters
- $attribute : string
- $value : mixed
- $parameters : array<string|int, mixed>
- $operator : string
Return values
bool —convertValuesToBoolean()
Convert the given values to boolean if they are string "true" / "false".
protected
convertValuesToBoolean(array<string|int, mixed> $values) : array<string|int, mixed>
Parameters
- $values : array<string|int, mixed>
Return values
array<string|int, mixed> —failsBasicDimensionChecks()
Test if the given width and height fail any conditions.
protected
failsBasicDimensionChecks(array<string|int, mixed> $parameters, int $width, int $height) : bool
Parameters
- $parameters : array<string|int, mixed>
- $width : int
- $height : int
Return values
bool —failsRatioCheck()
Determine if the given parameters fail a dimension ratio check.
protected
failsRatioCheck(array<string|int, mixed> $parameters, int $width, int $height) : bool
Parameters
- $parameters : array<string|int, mixed>
- $width : int
- $height : int
Return values
bool —getDateFormat()
Get the date format for an attribute if it has one.
protected
getDateFormat(string $attribute) : string|null
Parameters
- $attribute : string
Return values
string|null —getDateTimestamp()
Get the date timestamp.
protected
getDateTimestamp(mixed $value) : int
Parameters
- $value : mixed
Return values
int —getDateTimeWithOptionalFormat()
Get a DateTime instance from a string.
protected
getDateTimeWithOptionalFormat(string $format, string $value) : DateTime|null
Parameters
- $format : string
- $value : string
Return values
DateTime|null —getExistCount()
Get the number of records that exist in storage.
protected
getExistCount(mixed $connection, string $table, string $column, mixed $value, array<string|int, mixed> $parameters) : int
Parameters
- $connection : mixed
- $table : string
- $column : string
- $value : mixed
- $parameters : array<string|int, mixed>
Return values
int —getExtraConditions()
Get the extra conditions for a unique / exists rule.
protected
getExtraConditions(array<string|int, mixed> $segments) : array<string|int, mixed>
Parameters
- $segments : array<string|int, mixed>
Return values
array<string|int, mixed> —getQueryColumn()
Get the column name for an exists / unique query.
protected
getQueryColumn(array<string|int, mixed> $parameters, string $attribute) : bool
Parameters
- $parameters : array<string|int, mixed>
- $attribute : string
Return values
bool —getSize()
Get the size of an attribute.
protected
getSize(string $attribute, mixed $value) : mixed
Parameters
- $attribute : string
- $value : mixed
Return values
mixed —getUniqueExtra()
Get the extra conditions for a unique rule.
protected
getUniqueExtra(array<string|int, mixed> $parameters) : array<string|int, mixed>
Parameters
- $parameters : array<string|int, mixed>
Return values
array<string|int, mixed> —getUniqueIds()
Get the excluded ID column and value for the unique rule.
protected
getUniqueIds(array<string|int, mixed> $parameters) : array<string|int, mixed>
Parameters
- $parameters : array<string|int, mixed>
Return values
array<string|int, mixed> —parseNamedParameters()
Parse named parameters to $key => $value items.
protected
parseNamedParameters(array<string|int, mixed> $parameters) : array<string|int, mixed>
Parameters
- $parameters : array<string|int, mixed>
Return values
array<string|int, mixed> —parseTable()
Parse the connection / table for the unique / exists rules.
protected
parseTable(string $table) : array<string|int, mixed>
Parameters
- $table : string
Return values
array<string|int, mixed> —prepareUniqueId()
Prepare the given ID for querying.
protected
prepareUniqueId(mixed $id) : int
Parameters
- $id : mixed
Return values
int —requireParameterCount()
Require a certain number of parameters to be present.
protected
requireParameterCount(int $count, array<string|int, mixed> $parameters, string $rule) : void
Parameters
- $count : int
- $parameters : array<string|int, mixed>
- $rule : string
Tags
Return values
void —shouldBlockPhpUpload()
Check if PHP uploads are explicitly allowed.
protected
shouldBlockPhpUpload(mixed $value, array<string|int, mixed> $parameters) : bool
Parameters
- $value : mixed
- $parameters : array<string|int, mixed>