Validator
class Validator implements Validator (View source)
Traits
Properties
protected Translator | $translator | The Translator implementation. | |
protected Container | $container | The container instance. | |
protected PresenceVerifierInterface | $presenceVerifier | The Presence Verifier implementation. | |
protected array | $failedRules | The failed validation rules. | |
protected MessageBag | $messages | The message bag instance. | |
protected array | $data | The data under validation. | |
protected array | $initialRules | The initial rules provided. | |
protected array | $rules | The rules to be applied to the data. | |
protected string | $currentRule | The current rule that is validating. | |
protected array | $implicitAttributes | The array of wildcard attributes with their asterisks expanded. | |
protected array | $distinctValues | The cached data for the "distinct" rule. | |
protected array | $after | All of the registered "after" callbacks. | |
array | $customMessages | The array of custom error messages. | |
array | $fallbackMessages | The array of fallback error messages. | |
array | $customAttributes | The array of custom attribute names. | |
array | $customValues | The array of custom displayable values. | |
array | $extensions | All of the custom validator extensions. | |
array | $replacers | All of the custom replacer extensions. | |
protected array | $fileRules | The validation rules that may be applied to files. | |
protected array | $implicitRules | The validation rules that imply the field is required. | |
protected array | $dependentRules | The validation rules which depend on other fields as parameters. | |
protected array | $sizeRules | The size related validation rules. | |
protected array | $numericRules | The numeric related validation rules. |
Methods
Replace all place-holders for the between rule.
Replace all place-holders for the date_format rule.
Replace all place-holders for the different rule.
Replace all place-holders for the digits rule.
Replace all place-holders for the digits (between) rule.
Replace all place-holders for the min rule.
Replace all place-holders for the max rule.
Replace all place-holders for the in rule.
Replace all place-holders for the not_in rule.
Replace all place-holders for the in_array rule.
Replace all place-holders for the mimetypes rule.
Replace all place-holders for the mimes rule.
Replace all place-holders for the required_with rule.
Replace all place-holders for the required_with_all rule.
Replace all place-holders for the required_without rule.
Replace all place-holders for the required_without_all rule.
Replace all place-holders for the size rule.
Replace all place-holders for the gt rule.
Replace all place-holders for the lt rule.
Replace all place-holders for the gte rule.
Replace all place-holders for the lte rule.
Replace all place-holders for the required_if rule.
Replace all place-holders for the required_unless rule.
Replace all place-holders for the same rule.
Replace all place-holders for the before rule.
Replace all place-holders for the before_or_equal rule.
Replace all place-holders for the after rule.
Replace all place-holders for the after_or_equal rule.
Replace all place-holders for the date_equals rule.
Replace all place-holders for the dimensions rule.
Replace all place-holders for the ends_with rule.
Replace all place-holders for the starts_with rule.
Get the validation message for an attribute and rule.
Get the proper inline error message for standard and size rules.
Get the inline message for a rule if it exists.
Get the custom error message from translator.
Check the given messages for a wildcard key.
Get the proper error message for an attribute and size rule.
Get the data type of the given attribute.
Replace all error message place-holders with actual values.
Get the displayable name of the attribute.
Get the given attribute from the attribute translations.
Replace the :attribute placeholder in the given message.
Replace the :input placeholder in the given message.
Get the displayable name of the value.
Transform an array of attributes to their displayable form.
Call a custom validator message replacer.
Call a class based validator message replacer.
Validate that an attribute was "accepted".
Validate that an attribute is an active URL.
Validate the date is before a given date.
Validate the date is before or equal a given date.
Validate the date is after a given date.
Validate the date is equal or after a given date.
Compare a given date against another using an operator.
Get the date format for an attribute if it has one.
Given two date/time strings, check that one is after the other.
Get a DateTime instance from a string.
Get a DateTime instance from a string with no format.
Check if the given value should be adjusted to Carbon::getTestNow().
Validate that an attribute contains only alphabetic characters.
Validate that an attribute contains only alpha-numeric characters, dashes, and underscores.
Validate that an attribute contains only alpha-numeric characters.
Validate that an attribute is an array.
Validate the size of an attribute is between a set of values.
Validate that an attribute is a boolean.
Validate that an attribute has a matching confirmation.
Validate that an attribute is a valid date.
Validate that an attribute matches a date format.
Validate that an attribute is equal to another date.
Validate that an attribute is different from another attribute.
Validate that an attribute has a given number of digits.
Validate that an attribute is between a given number of digits.
Validate the dimensions of an image matches the given values.
Test if the given width and height fail any conditions.
Determine if the given parameters fail a dimension ratio check.
Validate an attribute is unique among other values.
Get the values to distinct between.
Extract the distinct values from the data.
Validate that an attribute is a valid e-mail address.
Validate the existence of an attribute value in a database table.
Get the number of records that exist in storage.
Validate the uniqueness of an attribute value on a given database table.
Get the excluded ID column and value for the unique rule.
Get the extra conditions for a unique rule.
Parse the connection / table for the unique / exists rules.
Get the column name for an exists / unique query.
Guess the database column from the given attribute name.
Get the extra conditions for a unique / exists rule.
Validate the given value is a valid file.
Validate the given attribute is filled if it is present.
Validate that an attribute is greater than another attribute.
Validate that an attribute is less than another attribute.
Validate that an attribute is greater than or equal another attribute.
Validate that an attribute is less than or equal another attribute.
Validate the MIME type of a file is an image MIME type.
Validate an attribute is contained within a list of values.
Validate that the values of an attribute is in another attribute.
Validate that an attribute is an integer.
Validate that an attribute is a valid IP.
Validate that an attribute is a valid IPv4.
Validate that an attribute is a valid IPv6.
Validate the attribute is a valid JSON string.
Validate the size of an attribute is less than a maximum value.
Validate the guessed extension of a file upload is in a set of file extensions.
Validate the MIME type of a file upload attribute is in a set of MIME types.
Check if PHP uploads are explicitly allowed.
Validate the size of an attribute is greater than a minimum value.
"Indicate" validation should pass if value is null.
Validate an attribute is not contained within a list of values.
Validate that an attribute is numeric.
Validate that the current logged in user's password matches the given value.
Validate that an attribute exists even if not filled.
Validate that an attribute passes a regular expression check.
Validate that an attribute does not pass a regular expression check.
Validate that a required attribute exists.
Validate that an attribute exists when another attribute has a given value.
Convert the given values to boolean if they are string "true" / "false".
Validate that an attribute exists when another attribute does not have a given value.
Validate that an attribute exists when any other attribute exists.
Validate that an attribute exists when all other attributes exists.
Validate that an attribute exists when another attribute does not.
Validate that an attribute exists when all other attributes do not.
Determine if any of the given attributes fail the required test.
Determine if all of the given attributes fail the required test.
Validate that two attributes match.
Validate the size of an attribute.
Validate the attribute starts with a given substring.
Validate the attribute ends with a given substring.
Validate that an attribute is a string.
Validate that an attribute is a valid timezone.
Validate that an attribute is a valid URL.
Validate that an attribute is a valid UUID.
Get the size of an attribute.
Check that the given value is a valid file instance.
Determine if a comparison passes between the given values.
Parse named parameters to $key => $value items.
Require a certain number of parameters to be present.
Check if the parameters are of the same type.
Adds the existing rule to the numericRules array if the attribute's value is numeric.
Create a new Validator instance.
Parse the data array, converting dots to ->.
Add an after validation callback.
Determine if the data passes the validation rules.
Determine if the data fails the validation rules.
Run the validator's rules against its data.
Get the attributes and values that were validated.
Validate a given attribute against a rule.
Determine if the given rule depends on other fields.
Get the explicit keys from an attribute flattened with dot notation.
Get the primary attribute name.
Replace each field parameter which has asterisks with the given keys.
Determine if the attribute is validatable.
Determine if the field is present, or the rule implies required.
Determine if a given rule implies the attribute is required.
Determine if the attribute passes any optional check.
Determine if the attribute fails the nullable check.
Determine if it's a necessary presence validation.
Validate an attribute using a custom rule object.
Check if we should stop further validations on a given attribute.
Add a failed rule and error message to the collection.
Returns the data which was valid.
Returns the data which was invalid.
Generate an array of all attributes that have messages.
Get the failed validation rules.
Get the message container for the validator.
An alternative more semantic shortcut to the message container.
Get the messages for the instance.
Determine if the given attribute has a rule in the given set.
Get a rule and its parameters for a given attribute.
Get the data under validation.
Get the data under validation.
Set the data under validation.
Get the value of a given attribute.
Get the validation rules.
Set the validation rules.
Parse the given rules and merge them into current rules.
Add conditions to a given field based on a Closure.
Register an array of custom validator extensions.
Register an array of custom implicit validator extensions.
Register an array of custom implicit validator extensions.
Register a custom implicit validator extension.
Register a custom dependent validator extension.
Register an array of custom validator message replacers.
Set the custom messages for the validator.
Set the custom attributes on the validator.
Add custom attributes to the validator.
Set the custom values on the validator.
Add the custom values for the validator.
Set the fallback messages for the validator.
Get the Presence Verifier implementation.
Get the Presence Verifier implementation.
Set the Presence Verifier implementation.
Get the Translator implementation.
Call a custom validator extension.
Call a class based validator extension.
Handle dynamic calls to class methods.
Details
in ReplacesAttributes at line 18
protected string
replaceBetween(string $message, string $attribute, string $rule, array $parameters)
Replace all place-holders for the between rule.
in ReplacesAttributes at line 32
protected string
replaceDateFormat(string $message, string $attribute, string $rule, array $parameters)
Replace all place-holders for the date_format rule.
in ReplacesAttributes at line 46
protected string
replaceDifferent(string $message, string $attribute, string $rule, array $parameters)
Replace all place-holders for the different rule.
in ReplacesAttributes at line 60
protected string
replaceDigits(string $message, string $attribute, string $rule, array $parameters)
Replace all place-holders for the digits rule.
in ReplacesAttributes at line 74
protected string
replaceDigitsBetween(string $message, string $attribute, string $rule, array $parameters)
Replace all place-holders for the digits (between) rule.
in ReplacesAttributes at line 88
protected string
replaceMin(string $message, string $attribute, string $rule, array $parameters)
Replace all place-holders for the min rule.
in ReplacesAttributes at line 102
protected string
replaceMax(string $message, string $attribute, string $rule, array $parameters)
Replace all place-holders for the max rule.
in ReplacesAttributes at line 116
protected string
replaceIn(string $message, string $attribute, string $rule, array $parameters)
Replace all place-holders for the in rule.
in ReplacesAttributes at line 134
protected string
replaceNotIn(string $message, string $attribute, string $rule, array $parameters)
Replace all place-holders for the not_in rule.
in ReplacesAttributes at line 148
protected string
replaceInArray(string $message, string $attribute, string $rule, array $parameters)
Replace all place-holders for the in_array rule.
in ReplacesAttributes at line 162
protected string
replaceMimetypes(string $message, string $attribute, string $rule, array $parameters)
Replace all place-holders for the mimetypes rule.
in ReplacesAttributes at line 176
protected string
replaceMimes(string $message, string $attribute, string $rule, array $parameters)
Replace all place-holders for the mimes rule.
in ReplacesAttributes at line 190
protected string
replaceRequiredWith(string $message, string $attribute, string $rule, array $parameters)
Replace all place-holders for the required_with rule.
in ReplacesAttributes at line 204
protected string
replaceRequiredWithAll(string $message, string $attribute, string $rule, array $parameters)
Replace all place-holders for the required_with_all rule.
in ReplacesAttributes at line 218
protected string
replaceRequiredWithout(string $message, string $attribute, string $rule, array $parameters)
Replace all place-holders for the required_without rule.
in ReplacesAttributes at line 232
protected string
replaceRequiredWithoutAll(string $message, string $attribute, string $rule, array $parameters)
Replace all place-holders for the required_without_all rule.
in ReplacesAttributes at line 246
protected string
replaceSize(string $message, string $attribute, string $rule, array $parameters)
Replace all place-holders for the size rule.
in ReplacesAttributes at line 260
protected string
replaceGt(string $message, string $attribute, string $rule, array $parameters)
Replace all place-holders for the gt rule.
in ReplacesAttributes at line 278
protected string
replaceLt(string $message, string $attribute, string $rule, array $parameters)
Replace all place-holders for the lt rule.
in ReplacesAttributes at line 296
protected string
replaceGte(string $message, string $attribute, string $rule, array $parameters)
Replace all place-holders for the gte rule.
in ReplacesAttributes at line 314
protected string
replaceLte(string $message, string $attribute, string $rule, array $parameters)
Replace all place-holders for the lte rule.
in ReplacesAttributes at line 332
protected string
replaceRequiredIf(string $message, string $attribute, string $rule, array $parameters)
Replace all place-holders for the required_if rule.
in ReplacesAttributes at line 350
protected string
replaceRequiredUnless(string $message, string $attribute, string $rule, array $parameters)
Replace all place-holders for the required_unless rule.
in ReplacesAttributes at line 372
protected string
replaceSame(string $message, string $attribute, string $rule, array $parameters)
Replace all place-holders for the same rule.
in ReplacesAttributes at line 386
protected string
replaceBefore(string $message, string $attribute, string $rule, array $parameters)
Replace all place-holders for the before rule.
in ReplacesAttributes at line 404
protected string
replaceBeforeOrEqual(string $message, string $attribute, string $rule, array $parameters)
Replace all place-holders for the before_or_equal rule.
in ReplacesAttributes at line 418
protected string
replaceAfter(string $message, string $attribute, string $rule, array $parameters)
Replace all place-holders for the after rule.
in ReplacesAttributes at line 432
protected string
replaceAfterOrEqual(string $message, string $attribute, string $rule, array $parameters)
Replace all place-holders for the after_or_equal rule.
in ReplacesAttributes at line 446
protected string
replaceDateEquals(string $message, string $attribute, string $rule, array $parameters)
Replace all place-holders for the date_equals rule.
in ReplacesAttributes at line 460
protected string
replaceDimensions(string $message, string $attribute, string $rule, array $parameters)
Replace all place-holders for the dimensions rule.
in ReplacesAttributes at line 482
protected string
replaceEndsWith(string $message, string $attribute, string $rule, array $parameters)
Replace all place-holders for the ends_with rule.
in ReplacesAttributes at line 500
protected string
replaceStartsWith(string $message, string $attribute, string $rule, array $parameters)
Replace all place-holders for the starts_with rule.
in FormatsMessages at line 21
protected string
getMessage(string $attribute, string $rule)
Get the validation message for an attribute and rule.
in FormatsMessages at line 73
protected string|null
getInlineMessage(string $attribute, string $rule)
Get the proper inline error message for standard and size rules.
in FormatsMessages at line 90
protected string|null
getFromLocalArray(string $attribute, string $lowerRule, array|null $source = null)
Get the inline message for a rule if it exists.
in FormatsMessages at line 114
protected string
getCustomMessageFromTranslator(string $key)
Get the custom error message from translator.
in FormatsMessages at line 140
protected string
getWildcardCustomMessages(array $messages, string $search, string $default)
Check the given messages for a wildcard key.
in FormatsMessages at line 158
protected string
getSizeMessage(string $attribute, string $rule)
Get the proper error message for an attribute and size rule.
in FormatsMessages at line 178
protected string
getAttributeType(string $attribute)
Get the data type of the given attribute.
in FormatsMessages at line 203
string
makeReplacements(string $message, string $attribute, string $rule, array $parameters)
Replace all error message place-holders with actual values.
in FormatsMessages at line 226
string
getDisplayableAttribute(string $attribute)
Get the displayable name of the attribute.
in FormatsMessages at line 265
protected string
getAttributeFromTranslations(string $name)
Get the given attribute from the attribute translations.
in FormatsMessages at line 277
protected string
replaceAttributePlaceholder(string $message, string $value)
Replace the :attribute placeholder in the given message.
in FormatsMessages at line 293
protected string
replaceInputPlaceholder(string $message, string $attribute)
Replace the :input placeholder in the given message.
in FormatsMessages at line 311
string
getDisplayableValue(string $attribute, mixed $value)
Get the displayable name of the value.
in FormatsMessages at line 336
protected array
getAttributeList(array $values)
Transform an array of attributes to their displayable form.
in FormatsMessages at line 360
protected string|null
callReplacer(string $message, string $attribute, string $rule, array $parameters, Validator $validator)
Call a custom validator message replacer.
in FormatsMessages at line 382
protected string
callClassBasedReplacer(string $callback, string $message, string $attribute, string $rule, array $parameters, Validator $validator)
Call a class based validator message replacer.
in ValidatesAttributes at line 40
bool
validateAccepted(string $attribute, mixed $value)
Validate that an attribute was "accepted".
This validation rule implies the attribute is "required".
in ValidatesAttributes at line 54
bool
validateActiveUrl(string $attribute, mixed $value)
Validate that an attribute is an active URL.
in ValidatesAttributes at line 78
bool
validateBail()
"Break" on first validation fail.
Always returns true, just lets us put "bail" in rules.
in ValidatesAttributes at line 91
bool
validateBefore(string $attribute, mixed $value, array $parameters)
Validate the date is before a given date.
in ValidatesAttributes at line 106
bool
validateBeforeOrEqual(string $attribute, mixed $value, array $parameters)
Validate the date is before or equal a given date.
in ValidatesAttributes at line 121
bool
validateAfter(string $attribute, mixed $value, array $parameters)
Validate the date is after a given date.
in ValidatesAttributes at line 136
bool
validateAfterOrEqual(string $attribute, mixed $value, array $parameters)
Validate the date is equal or after a given date.
in ValidatesAttributes at line 152
protected bool
compareDates(string $attribute, mixed $value, array $parameters, string $operator)
Compare a given date against another using an operator.
in ValidatesAttributes at line 175
protected string|null
getDateFormat(string $attribute)
Get the date format for an attribute if it has one.
in ValidatesAttributes at line 188
protected int
getDateTimestamp(mixed $value)
Get the date timestamp.
in ValidatesAttributes at line 214
protected bool
checkDateTimeOrder(string $format, string $first, string $second, string $operator)
Given two date/time strings, check that one is after the other.
in ValidatesAttributes at line 232
protected DateTime|null
getDateTimeWithOptionalFormat(string $format, string $value)
Get a DateTime instance from a string.
in ValidatesAttributes at line 247
protected DateTime|null
getDateTime(string $value)
Get a DateTime instance from a string with no format.
in ValidatesAttributes at line 266
protected bool
isTestingRelativeDateTime(mixed $value)
Check if the given value should be adjusted to Carbon::getTestNow().
in ValidatesAttributes at line 280
bool
validateAlpha(string $attribute, mixed $value)
Validate that an attribute contains only alphabetic characters.
in ValidatesAttributes at line 292
bool
validateAlphaDash(string $attribute, mixed $value)
Validate that an attribute contains only alpha-numeric characters, dashes, and underscores.
in ValidatesAttributes at line 308
bool
validateAlphaNum(string $attribute, mixed $value)
Validate that an attribute contains only alpha-numeric characters.
in ValidatesAttributes at line 324
bool
validateArray(string $attribute, mixed $value)
Validate that an attribute is an array.
in ValidatesAttributes at line 337
bool
validateBetween(string $attribute, mixed $value, array $parameters)
Validate the size of an attribute is between a set of values.
in ValidatesAttributes at line 353
bool
validateBoolean(string $attribute, mixed $value)
Validate that an attribute is a boolean.
in ValidatesAttributes at line 367
bool
validateConfirmed(string $attribute, mixed $value)
Validate that an attribute has a matching confirmation.
in ValidatesAttributes at line 379
bool
validateDate(string $attribute, mixed $value)
Validate that an attribute is a valid date.
in ValidatesAttributes at line 402
bool
validateDateFormat(string $attribute, mixed $value, array $parameters)
Validate that an attribute matches a date format.
in ValidatesAttributes at line 425
bool
validateDateEquals(string $attribute, mixed $value, array $parameters)
Validate that an attribute is equal to another date.
in ValidatesAttributes at line 440
bool
validateDifferent(string $attribute, mixed $value, array $parameters)
Validate that an attribute is different from another attribute.
in ValidatesAttributes at line 467
bool
validateDigits(string $attribute, mixed $value, array $parameters)
Validate that an attribute has a given number of digits.
in ValidatesAttributes at line 483
bool
validateDigitsBetween(string $attribute, mixed $value, array $parameters)
Validate that an attribute is between a given number of digits.
in ValidatesAttributes at line 501
bool
validateDimensions(string $attribute, mixed $value, array $parameters)
Validate the dimensions of an image matches the given values.
in ValidatesAttributes at line 533
protected bool
failsBasicDimensionChecks(array $parameters, int $width, int $height)
Test if the given width and height fail any conditions.
in ValidatesAttributes at line 551
protected bool
failsRatioCheck(array $parameters, int $width, int $height)
Determine if the given parameters fail a dimension ratio check.
in ValidatesAttributes at line 574
bool
validateDistinct(string $attribute, mixed $value, array $parameters)
Validate an attribute is unique among other values.
in ValidatesAttributes at line 591
protected array
getDistinctValues(string $attribute)
Get the values to distinct between.
in ValidatesAttributes at line 612
protected array
extractDistinctValues(string $attribute)
Extract the distinct values from the data.
in ValidatesAttributes at line 633
bool
validateEmail(string $attribute, mixed $value, array $parameters)
Validate that an attribute is a valid e-mail address.
in ValidatesAttributes at line 668
bool
validateExists(string $attribute, mixed $value, array $parameters)
Validate the existence of an attribute value in a database table.
in ValidatesAttributes at line 696
protected int
getExistCount(mixed $connection, string $table, string $column, mixed $value, array $parameters)
Get the number of records that exist in storage.
in ValidatesAttributes at line 723
bool
validateUnique(string $attribute, mixed $value, array $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.
in ValidatesAttributes at line 766
protected array
getUniqueIds(array $parameters)
Get the excluded ID column and value for the unique rule.
in ValidatesAttributes at line 779
protected int
prepareUniqueId(mixed $id)
Prepare the given ID for querying.
in ValidatesAttributes at line 802
protected array
getUniqueExtra(array $parameters)
Get the extra conditions for a unique rule.
in ValidatesAttributes at line 817
array
parseTable(string $table)
Parse the connection / table for the unique / exists rules.
in ValidatesAttributes at line 839
bool
getQueryColumn(array $parameters, string $attribute)
Get the column name for an exists / unique query.
in ValidatesAttributes at line 851
string
guessColumnForQuery(string $attribute)
Guess the database column from the given attribute name.
in ValidatesAttributes at line 867
protected array
getExtraConditions(array $segments)
Get the extra conditions for a unique / exists rule.
in ValidatesAttributes at line 887
bool
validateFile(string $attribute, mixed $value)
Validate the given value is a valid file.
in ValidatesAttributes at line 899
bool
validateFilled(string $attribute, mixed $value)
Validate the given attribute is filled if it is present.
in ValidatesAttributes at line 916
bool
validateGt(string $attribute, mixed $value, array $parameters)
Validate that an attribute is greater than another attribute.
in ValidatesAttributes at line 947
bool
validateLt(string $attribute, mixed $value, array $parameters)
Validate that an attribute is less than another attribute.
in ValidatesAttributes at line 978
bool
validateGte(string $attribute, mixed $value, array $parameters)
Validate that an attribute is greater than or equal another attribute.
in ValidatesAttributes at line 1009
bool
validateLte(string $attribute, mixed $value, array $parameters)
Validate that an attribute is less than or equal another attribute.
in ValidatesAttributes at line 1039
bool
validateImage(string $attribute, mixed $value)
Validate the MIME type of a file is an image MIME type.
in ValidatesAttributes at line 1052
bool
validateIn(string $attribute, mixed $value, array $parameters)
Validate an attribute is contained within a list of values.
in ValidatesAttributes at line 1075
bool
validateInArray(string $attribute, mixed $value, array $parameters)
Validate that the values of an attribute is in another attribute.
in ValidatesAttributes at line 1097
bool
validateInteger(string $attribute, mixed $value)
Validate that an attribute is an integer.
in ValidatesAttributes at line 1109
bool
validateIp(string $attribute, mixed $value)
Validate that an attribute is a valid IP.
in ValidatesAttributes at line 1121
bool
validateIpv4(string $attribute, mixed $value)
Validate that an attribute is a valid IPv4.
in ValidatesAttributes at line 1133
bool
validateIpv6(string $attribute, mixed $value)
Validate that an attribute is a valid IPv6.
in ValidatesAttributes at line 1145
bool
validateJson(string $attribute, mixed $value)
Validate the attribute is a valid JSON string.
in ValidatesAttributes at line 1164
bool
validateMax(string $attribute, mixed $value, array $parameters)
Validate the size of an attribute is less than a maximum value.
in ValidatesAttributes at line 1183
bool
validateMimes(string $attribute, mixed $value, array $parameters)
Validate the guessed extension of a file upload is in a set of file extensions.
in ValidatesAttributes at line 1204
bool
validateMimetypes(string $attribute, mixed $value, array $parameters)
Validate the MIME type of a file upload attribute is in a set of MIME types.
in ValidatesAttributes at line 1226
protected bool
shouldBlockPhpUpload(mixed $value, array $parameters)
Check if PHP uploads are explicitly allowed.
in ValidatesAttributes at line 1249
bool
validateMin(string $attribute, mixed $value, array $parameters)
Validate the size of an attribute is greater than a minimum value.
in ValidatesAttributes at line 1263
bool
validateNullable()
"Indicate" validation should pass if value is null.
Always returns true, just lets us put "nullable" in rules.
in ValidatesAttributes at line 1276
bool
validateNotIn(string $attribute, mixed $value, array $parameters)
Validate an attribute is not contained within a list of values.
in ValidatesAttributes at line 1288
bool
validateNumeric(string $attribute, mixed $value)
Validate that an attribute is numeric.
in ValidatesAttributes at line 1301
protected bool
validatePassword(string $attribute, mixed $value, array $parameters)
Validate that the current logged in user's password matches the given value.
in ValidatesAttributes at line 1322
bool
validatePresent(string $attribute, mixed $value)
Validate that an attribute exists even if not filled.
in ValidatesAttributes at line 1335
bool
validateRegex(string $attribute, mixed $value, array $parameters)
Validate that an attribute passes a regular expression check.
in ValidatesAttributes at line 1354
bool
validateNotRegex(string $attribute, mixed $value, array $parameters)
Validate that an attribute does not pass a regular expression check.
in ValidatesAttributes at line 1372
bool
validateRequired(string $attribute, mixed $value)
Validate that a required attribute exists.
in ValidatesAttributes at line 1395
bool
validateRequiredIf(string $attribute, mixed $value, mixed $parameters)
Validate that an attribute exists when another attribute has a given value.
in ValidatesAttributes at line 1420
protected array
convertValuesToBoolean(array $values)
Convert the given values to boolean if they are string "true" / "false".
in ValidatesAttributes at line 1441
bool
validateRequiredUnless(string $attribute, mixed $value, mixed $parameters)
Validate that an attribute exists when another attribute does not have a given value.
in ValidatesAttributes at line 1464
bool
validateRequiredWith(string $attribute, mixed $value, mixed $parameters)
Validate that an attribute exists when any other attribute exists.
in ValidatesAttributes at line 1481
bool
validateRequiredWithAll(string $attribute, mixed $value, mixed $parameters)
Validate that an attribute exists when all other attributes exists.
in ValidatesAttributes at line 1498
bool
validateRequiredWithout(string $attribute, mixed $value, mixed $parameters)
Validate that an attribute exists when another attribute does not.
in ValidatesAttributes at line 1515
bool
validateRequiredWithoutAll(string $attribute, mixed $value, mixed $parameters)
Validate that an attribute exists when all other attributes do not.
in ValidatesAttributes at line 1530
protected bool
anyFailingRequired(array $attributes)
Determine if any of the given attributes fail the required test.
in ValidatesAttributes at line 1547
protected bool
allFailingRequired(array $attributes)
Determine if all of the given attributes fail the required test.
in ValidatesAttributes at line 1566
bool
validateSame(string $attribute, mixed $value, array $parameters)
Validate that two attributes match.
in ValidatesAttributes at line 1583
bool
validateSize(string $attribute, mixed $value, array $parameters)
Validate the size of an attribute.
in ValidatesAttributes at line 1597
bool
validateSometimes()
"Validate" optional attributes.
Always returns true, just lets us put sometimes in rules.
in ValidatesAttributes at line 1610
bool
validateStartsWith(string $attribute, mixed $value, array $parameters)
Validate the attribute starts with a given substring.
in ValidatesAttributes at line 1623
bool
validateEndsWith(string $attribute, mixed $value, array $parameters)
Validate the attribute ends with a given substring.
in ValidatesAttributes at line 1635
bool
validateString(string $attribute, mixed $value)
Validate that an attribute is a string.
in ValidatesAttributes at line 1647
bool
validateTimezone(string $attribute, mixed $value)
Validate that an attribute is a valid timezone.
in ValidatesAttributes at line 1667
bool
validateUrl(string $attribute, mixed $value)
Validate that an attribute is a valid URL.
in ValidatesAttributes at line 1704
bool
validateUuid(string $attribute, mixed $value)
Validate that an attribute is a valid UUID.
in ValidatesAttributes at line 1720
protected mixed
getSize(string $attribute, mixed $value)
Get the size of an attribute.
in ValidatesAttributes at line 1745
bool
isValidFileInstance(mixed $value)
Check that the given value is a valid file instance.
in ValidatesAttributes at line 1764
protected bool
compare(mixed $first, mixed $second, string $operator)
Determine if a comparison passes between the given values.
in ValidatesAttributes at line 1788
protected array
parseNamedParameters(array $parameters)
Parse named parameters to $key => $value items.
in ValidatesAttributes at line 1809
void
requireParameterCount(int $count, array $parameters, string $rule)
Require a certain number of parameters to be present.
in ValidatesAttributes at line 1823
protected bool
isSameType(mixed $first, mixed $second)
Check if the parameters are of the same type.
in ValidatesAttributes at line 1836
protected void
shouldBeNumeric(string $attribute, string $rule)
Adds the existing rule to the numericRules array if the attribute's value is numeric.
at line 204
void
__construct(Translator $translator, array $data, array $rules, array $messages = [], array $customAttributes = [])
Create a new Validator instance.
at line 222
array
parseData(array $data)
Parse the data array, converting dots to ->.
at line 250
$this
after(callable|string $callback)
Add an after validation callback.
at line 264
bool
passes()
Determine if the data passes the validation rules.
at line 300
bool
fails()
Determine if the data fails the validation rules.
at line 312
array
validate()
Run the validator's rules against its data.
at line 328
array
validated()
Get the attributes and values that were validated.
at line 356
protected void
validateAttribute(string $attribute, string $rule)
Validate a given attribute against a rule.
at line 409
protected bool
dependsOnOtherFields(string $rule)
Determine if the given rule depends on other fields.
at line 422
protected array
getExplicitKeys(string $attribute)
Get the explicit keys from an attribute flattened with dot notation.
E.g. 'foo.1.bar.spark.baz' -> [1, 'spark'] for 'foo..bar..baz'
at line 443
protected string
getPrimaryAttribute(string $attribute)
Get the primary attribute name.
For example, if "name.0" is given, "name.*" will be returned.
at line 461
protected array
replaceAsterisksInParameters(array $parameters, array $keys)
Replace each field parameter which has asterisks with the given keys.
at line 476
protected bool
isValidatable(object|string $rule, string $attribute, mixed $value)
Determine if the attribute is validatable.
at line 492
protected bool
presentOrRuleIsImplicit(object|string $rule, string $attribute, mixed $value)
Determine if the field is present, or the rule implies required.
at line 508
protected bool
isImplicit(object|string $rule)
Determine if a given rule implies the attribute is required.
at line 520
protected bool
passesOptionalCheck(string $attribute)
Determine if the attribute passes any optional check.
at line 539
protected bool
isNotNullIfMarkedAsNullable(string $rule, string $attribute)
Determine if the attribute fails the nullable check.
at line 557
protected bool
hasNotFailedPreviousRuleIfPresenceRule(string $rule, string $attribute)
Determine if it's a necessary presence validation.
This is to avoid possible database type comparison errors.
at line 570
protected void
validateUsingCustomRule(string $attribute, mixed $value, Rule $rule)
Validate an attribute using a custom rule object.
at line 591
protected bool
shouldStopValidating(string $attribute)
Check if we should stop further validations on a given attribute.
at line 618
void
addFailure(string $attribute, string $rule, array $parameters = [])
Add a failed rule and error message to the collection.
at line 636
array
valid()
Returns the data which was valid.
at line 652
array
invalid()
Returns the data which was invalid.
at line 678
protected array
attributesThatHaveMessages()
Generate an array of all attributes that have messages.
at line 690
array
failed()
Get the failed validation rules.
at line 700
MessageBag
messages()
Get the message container for the validator.
at line 714
MessageBag
errors()
An alternative more semantic shortcut to the message container.
at line 724
MessageBag
getMessageBag()
Get the messages for the instance.
at line 736
bool
hasRule(string $attribute, string|array $rules)
Determine if the given attribute has a rule in the given set.
at line 748
protected array|null
getRule(string $attribute, string|array $rules)
Get a rule and its parameters for a given attribute.
at line 770
array
attributes()
Get the data under validation.
at line 780
array
getData()
Get the data under validation.
at line 791
$this
setData(array $data)
Set the data under validation.
at line 806
protected mixed
getValue(string $attribute)
Get the value of a given attribute.
at line 816
array
getRules()
Get the validation rules.
at line 827
$this
setRules(array $rules)
Set the validation rules.
at line 844
void
addRules(array $rules)
Parse the given rules and merge them into current rules.
at line 869
$this
sometimes(string|array $attribute, string|array $rules, callable $callback)
Add conditions to a given field based on a Closure.
at line 888
void
addExtensions(array $extensions)
Register an array of custom validator extensions.
at line 905
void
addImplicitExtensions(array $extensions)
Register an array of custom implicit validator extensions.
at line 920
void
addDependentExtensions(array $extensions)
Register an array of custom implicit validator extensions.
at line 936
void
addExtension(string $rule, Closure|string $extension)
Register a custom validator extension.
at line 948
void
addImplicitExtension(string $rule, Closure|string $extension)
Register a custom implicit validator extension.
at line 962
void
addDependentExtension(string $rule, Closure|string $extension)
Register a custom dependent validator extension.
at line 975
void
addReplacers(array $replacers)
Register an array of custom validator message replacers.
at line 993
void
addReplacer(string $rule, Closure|string $replacer)
Register a custom validator message replacer.
at line 1004
$this
setCustomMessages(array $messages)
Set the custom messages for the validator.
at line 1017
$this
setAttributeNames(array $attributes)
Set the custom attributes on the validator.
at line 1030
$this
addCustomAttributes(array $customAttributes)
Add custom attributes to the validator.
at line 1043
$this
setValueNames(array $values)
Set the custom values on the validator.
at line 1056
$this
addCustomValues(array $customValues)
Add the custom values for the validator.
at line 1069
void
setFallbackMessages(array $messages)
Set the fallback messages for the validator.
at line 1081
PresenceVerifierInterface
getPresenceVerifier()
Get the Presence Verifier implementation.
at line 1098
PresenceVerifierInterface
getPresenceVerifierFor(string $connection)
Get the Presence Verifier implementation.
at line 1111
void
setPresenceVerifier(PresenceVerifierInterface $presenceVerifier)
Set the Presence Verifier implementation.
at line 1121
Translator
getTranslator()
Get the Translator implementation.
at line 1132
void
setTranslator(Translator $translator)
Set the Translator implementation.
at line 1155
protected bool|null
callExtension(string $rule, array $parameters)
Call a custom validator extension.
at line 1173
protected bool
callClassBasedExtension(string $callback, array $parameters)
Call a class based validator extension.
at line 1189
mixed
__call(string $method, array $parameters)
Handle dynamic calls to class methods.