Validator
class Validator implements Validator
Traits
Execute compiled AttributePlans against validation data.
Properties
| protected Container|null | $container | The container instance. |
|
| protected PresenceVerifierInterface|null | $presenceVerifier | The Presence Verifier implementation. |
|
| protected array | $failedRules | The failed validation rules. |
|
| protected array<string, string> | $excludeAttributes | Attributes that should be excluded from the validated data. |
|
| protected MessageBag|null | $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 array|object|string|null | $currentRule | The current rule that is validating. |
|
| protected array | $implicitAttributes | The array of wildcard attributes with their asterisks expanded. |
|
| protected Closure|null | $implicitAttributesFormatter | The callback that should be used to format the attribute. |
|
| protected array | $distinctValues | The cached data for the "distinct" rule. |
|
| protected array<string, array{counts: array<string, int>, looseType: null|string}> | $distinctValueCounts | Typed occurrence counts for each distinct attribute during this validation pass. |
|
| protected AttributePlan> | $compiledPlans | The compiled execution plans for the current passes() invocation. |
|
| protected PresenceVerifierInterface|null | $originalPresenceVerifier | The original presence verifier, saved during batched DB checks. |
|
| 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. |
|
| protected bool | $stopOnFirstFailure | Indicates if the validator should stop on the first rule failure. |
|
| bool | $excludeUnvalidatedArrayKeys | Indicates that unvalidated array keys should be excluded, even if the parent array was validated. |
|
| array | $extensions | All of the custom validator extensions. |
|
| array | $replacers | All of the custom replacer extensions. |
|
| protected string[] | $fileRules | The validation rules that may be applied to files. |
|
| protected string[] | $implicitRules | The validation rules that imply the field is required. |
|
| protected string[] | $dependentRules | The validation rules which depend on other fields as parameters. |
|
| protected array<string, int> | $literalParameterOffsets | The position of the first literal parameter in dependent rules. |
|
| protected string[] | $excludeRules | The validation rules that can exclude an attribute. |
|
| protected string[] | $sizeRules | The size related validation rules. |
|
| protected string[] | $numericRules | The numeric related validation rules. |
|
| protected string[] | $defaultNumericRules | The default numeric related validation rules. |
|
| static protected bool | $fakeDnsLookups | Indicates if DNS lookups performed by validation rules should be faked to always succeed. |
|
| static protected null|array<string, true> | $encodingNames | The lowercase names of the encodings supported by mbstring. |
|
| static protected null|array<string, true> | $timezoneIdentifiers | The identifiers of every timezone. |
|
| protected ValidationException>|ValidationException | $exception | The exception to throw upon failure. |
|
| protected Closure|null | $ensureExponentWithinAllowedRangeUsing | The custom callback to determine if an exponent is within allowed range. |
Methods
Replace all place-holders for the accepted_if rule.
Replace all place-holders for the declined_if rule.
Replace all place-holders for the between rule.
Replace all place-holders for the date_format rule.
Replace all place-holders for the decimal 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 encoding rule.
Replace all place-holders for the extensions rule.
Replace all place-holders for the min rule.
Replace all place-holders for the min digits rule.
Replace all place-holders for the max rule.
Replace all place-holders for the max digits rule.
Replace all place-holders for the missing_if rule.
Replace all place-holders for the missing_unless rule.
Replace all place-holders for the missing_with rule.
Replace all place-holders for the missing_with_all rule.
Replace all place-holders for the multiple_of 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 in_array_keys rule.
Replace all place-holders for the array_keys rule.
Replace all place-holders for the required_array_keys rule.
Replace all place-holders for the mimetypes rule.
Replace all place-holders for the mimes rule.
Replace all place-holders for the present_if rule.
Replace all place-holders for the present_unless rule.
Replace all place-holders for the present_with rule.
Replace all place-holders for the present_with_all 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_if_accepted rule.
Replace all place-holders for the required_if_declined rule.
Replace all place-holders for the required_unless rule.
Replace all place-holders for the prohibited_if rule.
Replace all place-holders for the prohibited_if_accepted rule.
Replace all place-holders for the prohibited_if_declined rule.
Replace all place-holders for the prohibited_unless rule.
Replace all place-holders for the prohibited_with 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 doesnt_end_with rule.
Replace all place-holders for the starts_with rule.
Replace all place-holders for the doesnt_start_with rule.
Replace all place-holders for the doesnt_contain 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 the translator.
Check the given messages for a wildcard key.
Build a wildcard message pattern that preserves literal path segments.
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.
Get the custom name for an attribute if it exists in the given array.
Replace the :attribute placeholder in the given message.
Replace the :index placeholder in the given message.
Replace the :position placeholder in the given message.
Replace the :ordinal-position placeholder in the given message.
Replace the :index or :position placeholder in the given message.
Get the word for a index or position segment.
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 was "accepted" when another attribute has a given value.
Validate that an attribute was "declined".
Validate that an attribute was "declined" when another attribute has a given value.
Validate that an attribute is an active URL.
Get the DNS records for the given hostname.
Validate that an attribute is 7 bit ASCII.
Validate that an attribute is a valid Base64 string.
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.
Compare a date value with a literal or referenced field using the given format.
Get a DateTime instance from a supported value using the given format.
Get a DateTime instance from a string with no format.
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.
Get the accepted literal and encoded array keys.
Validate that an array does not contain any keys other than the given keys.
Validate that an attribute is a list.
Validate that an array has all of the given keys.
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 an attribute contains a list of values.
Validate an attribute does not contain a list of values.
Validate that the password of the currently authenticated user matches the given value.
Validate that an attribute is a valid date.
Validate that an attribute matches a date format.
Determine if a value matches a specific date format.
Validate that an attribute is equal to another date.
Validate that an attribute has a given number of decimal places.
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.
Identify values whose strict equality can be counted without comparing every sibling.
Get the values to distinct between.
Extract the distinct values from the data.
Validate that an attribute is a valid e-mail address.
Determine if a value is a valid email address using basic RFC validation.
Validate the encoding of an attribute.
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.
Prepare the given ID for querying.
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 extension of a file upload attribute is in a set of defined extensions.
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 that an attribute is lowercase.
Validate that an attribute is uppercase.
Validate that an attribute is a valid HEX color.
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 are in another attribute.
Validate that an array contains at least one of the given keys.
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.
Determine if a value is a valid IP address (any version).
Determine if a value is a valid IPv4 address.
Determine if a value is a valid IPv6 address.
Validate that an attribute is a valid MAC address.
Validate the attribute is a valid JSON string.
Validate the size of an attribute is less than or equal to a maximum value.
Validate that an attribute has a maximum number of digits.
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 or equal to a minimum value.
Validate that an attribute has a minimum number of digits.
Validate that an attribute is missing.
Validate that an attribute is missing when another attribute has a given value.
Validate that an attribute is missing unless another attribute has a given value.
Validate that an attribute is missing when any given attribute is present.
Validate that an attribute is missing when all given attributes are present.
Validate the value of an attribute is a multiple of a given 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 an attribute exists even if not filled.
Validate that an attribute is present when another attribute has a given value.
Validate that an attribute is present unless another attribute has a given value.
Validate that an attribute is present when any given attribute is present.
Validate that an attribute is present when all given attributes are present.
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.
Validate that an attribute exists when another attribute was "accepted".
Validate that an attribute exists when another attribute was "declined".
Validate that an attribute does not exist or is an empty string.
Validate that an attribute does not exist when another attribute has a given value.
Validate that an attribute does not exist when another attribute was "accepted".
Validate that an attribute does not exist when another attribute was "declined".
Validate that an attribute does not exist unless another attribute has a given value.
Validate that other attributes do not exist when this attribute exists.
Indicate that an attribute should be excluded when another attribute has a given value.
Indicate that an attribute should be excluded when another attribute does not have a given value.
Validate that an attribute exists when another attribute does not have a given value.
Indicate that an attribute should be excluded when another attribute presents.
Indicate that an attribute should be excluded when another attribute is missing.
Prepare the values and the other value for validation.
Check if parameter should be converted to boolean.
Convert the given values to boolean if they are string "true" / "false".
Convert the given values to null if they are string "null".
Validate that an attribute exists when any other attribute exists.
Validate that an attribute exists when all other attributes exist.
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 does not start with a given substring.
Validate the attribute ends with a given substring.
Validate the attribute does not end 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 ULID.
Validate that an attribute is a valid UUID.
Determine if a value is a valid UUID (any version).
Get the size of an attribute.
Compute the validation size from numeric semantics and runtime value shape.
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.
Ensure the exponent is within the allowed range.
Execute all compiled plans against the validation data.
Execute all-delegated plans for a Validator subclass.
Determine if a non-implicit check should be skipped.
Determine if an invalid upload should fail before rule execution.
Determine if an inline check is safe to repeat during presence preflight.
Execute an inline check against a value.
Create a new Validator instance.
Parse the data array, converting dots and asterisks.
Replace the placeholders used in data keys.
Replace the placeholders in the given string.
Replace each field parameter key placeholder.
Determine if the data passes the validation rules.
Compile all attribute rules into AttributePlans.
Determine if any compiled check can mutate this validator's data.
Pre-evaluate safe first-position exclusion checks.
Batch safe database-presence candidates by query shape.
Determine if the data fails the validation rules.
Execute the callback if the data passes the validation rules.
Execute the callback if the data fails the validation rules.
Determine if the attribute should be excluded.
Remove the given attribute.
Run the validator's rules against its data.
Run the validator's rules against its data.
Get a validated input container for the validated input.
Get the attributes and values that were validated.
Get the rule keys that have nested rules beneath them.
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.
Resolve field parameters without rewriting literal comparison or database values.
Replace each escaped field parameter separator with its placeholder.
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.
Add the given attribute to the list of excluded attributes.
Return the data which was valid.
Return 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.
Get the value of a given attribute.
Set the value of a given attribute.
Get the validation rules.
Get the validation rules with key placeholders removed.
Retain the selected rules from the graph prepared for the current data.
Append new validation rules to the validator.
Parse the given rules and merge them into current rules.
Add conditions to a given field based on a Closure.
Instruct the validator to stop validating after the first rule failure.
Register an array of custom validator extensions.
Register an array of custom implicit validator extensions.
Register an array of custom dependent 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 callback that used to format an implicit attribute.
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.
Set the Presence Verifier implementation.
Get the exception to throw upon failed validation.
Ensure exponents are within range using the given callback.
Get the Translator implementation.
Call a custom validator extension.
Call a class based validator extension.
Encode the attribute with the placeholder hash.
Decode an attribute with a placeholder hash.
Fake the DNS lookups performed by validation rules so they always succeed.
Flush all static state.
Handle dynamic calls to class methods.
Details
in
ReplacesAttributes at line 18
protected string
replaceAcceptedIf(string $message, string $attribute, string $rule, array $parameters)
Replace all place-holders for the accepted_if rule.
in
ReplacesAttributes at line 32
protected string
replaceDeclinedIf(string $message, string $attribute, string $rule, array $parameters)
Replace all place-holders for the declined_if rule.
in
ReplacesAttributes at line 42
protected string
replaceBetween(string $message, string $attribute, string $rule, array $parameters)
Replace all place-holders for the between rule.
in
ReplacesAttributes at line 52
protected string
replaceDateFormat(string $message, string $attribute, string $rule, array $parameters)
Replace all place-holders for the date_format rule.
in
ReplacesAttributes at line 62
protected string
replaceDecimal(string $message, string $attribute, string $rule, array $parameters)
Replace all place-holders for the decimal rule.
in
ReplacesAttributes at line 78
protected string
replaceDifferent(string $message, string $attribute, string $rule, array $parameters)
Replace all place-holders for the different rule.
in
ReplacesAttributes at line 88
protected string
replaceDigits(string $message, string $attribute, string $rule, array $parameters)
Replace all place-holders for the digits rule.
in
ReplacesAttributes at line 98
protected string
replaceDigitsBetween(string $message, string $attribute, string $rule, array $parameters)
Replace all place-holders for the digits (between) rule.
in
ReplacesAttributes at line 108
protected string
replaceEncoding(string $message, string $attribute, string $rule, array $parameters)
Replace all place-holders for the encoding rule.
in
ReplacesAttributes at line 118
protected string
replaceExtensions(string $message, string $attribute, string $rule, array $parameters)
Replace all place-holders for the extensions rule.
in
ReplacesAttributes at line 128
protected string
replaceMin(string $message, string $attribute, string $rule, array $parameters)
Replace all place-holders for the min rule.
in
ReplacesAttributes at line 138
protected string
replaceMinDigits(string $message, string $attribute, string $rule, array $parameters)
Replace all place-holders for the min digits rule.
in
ReplacesAttributes at line 148
protected string
replaceMax(string $message, string $attribute, string $rule, array $parameters)
Replace all place-holders for the max rule.
in
ReplacesAttributes at line 158
protected string
replaceMaxDigits(string $message, string $attribute, string $rule, array $parameters)
Replace all place-holders for the max digits rule.
in
ReplacesAttributes at line 168
protected string
replaceMissingIf(string $message, string $attribute, string $rule, array $parameters)
Replace all place-holders for the missing_if rule.
in
ReplacesAttributes at line 178
protected string
replaceMissingUnless(string $message, string $attribute, string $rule, array $parameters)
Replace all place-holders for the missing_unless rule.
in
ReplacesAttributes at line 191
protected string
replaceMissingWith(string $message, string $attribute, string $rule, array $parameters)
Replace all place-holders for the missing_with rule.
in
ReplacesAttributes at line 209
protected string
replaceMissingWithAll(string $message, string $attribute, string $rule, array $parameters)
Replace all place-holders for the missing_with_all rule.
in
ReplacesAttributes at line 219
protected string
replaceMultipleOf(string $message, string $attribute, string $rule, array $parameters)
Replace all place-holders for the multiple_of rule.
in
ReplacesAttributes at line 229
protected string
replaceIn(string $message, string $attribute, string $rule, array $parameters)
Replace all place-holders for the in rule.
in
ReplacesAttributes at line 251
protected string
replaceNotIn(string $message, string $attribute, string $rule, array $parameters)
Replace all place-holders for the not_in rule.
in
ReplacesAttributes at line 261
protected string
replaceInArray(string $message, string $attribute, string $rule, array $parameters)
Replace all place-holders for the in_array rule.
in
ReplacesAttributes at line 273
protected string
replaceInArrayKeys(string $message, string $attribute, string $rule, array $parameters)
Replace all place-holders for the in_array_keys rule.
in
ReplacesAttributes at line 283
protected string
replaceArrayKeys(string $message, string $attribute, string $rule, array $parameters)
Replace all place-holders for the array_keys rule.
in
ReplacesAttributes at line 306
protected string
replaceRequiredArrayKeys(string $message, string $attribute, string $rule, array $parameters)
Replace all place-holders for the required_array_keys rule.
in
ReplacesAttributes at line 316
protected string
replaceMimetypes(string $message, string $attribute, string $rule, array $parameters)
Replace all place-holders for the mimetypes rule.
in
ReplacesAttributes at line 326
protected string
replaceMimes(string $message, string $attribute, string $rule, array $parameters)
Replace all place-holders for the mimes rule.
in
ReplacesAttributes at line 345
protected string
replacePresentIf(string $message, string $attribute, string $rule, array $parameters)
Replace all place-holders for the present_if rule.
in
ReplacesAttributes at line 355
protected string
replacePresentUnless(string $message, string $attribute, string $rule, array $parameters)
Replace all place-holders for the present_unless rule.
in
ReplacesAttributes at line 365
protected string
replacePresentWith(string $message, string $attribute, string $rule, array $parameters)
Replace all place-holders for the present_with rule.
in
ReplacesAttributes at line 383
protected string
replacePresentWithAll(string $message, string $attribute, string $rule, array $parameters)
Replace all place-holders for the present_with_all rule.
in
ReplacesAttributes at line 393
protected string
replaceRequiredWith(string $message, string $attribute, string $rule, array $parameters)
Replace all place-holders for the required_with rule.
in
ReplacesAttributes at line 411
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 421
protected string
replaceRequiredWithout(string $message, string $attribute, string $rule, array $parameters)
Replace all place-holders for the required_without rule.
in
ReplacesAttributes at line 431
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 441
protected string
replaceSize(string $message, string $attribute, string $rule, array $parameters)
Replace all place-holders for the size rule.
in
ReplacesAttributes at line 451
protected string
replaceGt(string $message, string $attribute, string $rule, array $parameters)
Replace all place-holders for the gt rule.
in
ReplacesAttributes at line 472
protected string
replaceLt(string $message, string $attribute, string $rule, array $parameters)
Replace all place-holders for the lt rule.
in
ReplacesAttributes at line 482
protected string
replaceGte(string $message, string $attribute, string $rule, array $parameters)
Replace all place-holders for the gte rule.
in
ReplacesAttributes at line 492
protected string
replaceLte(string $message, string $attribute, string $rule, array $parameters)
Replace all place-holders for the lte rule.
in
ReplacesAttributes at line 502
protected string
replaceRequiredIf(string $message, string $attribute, string $rule, array $parameters)
Replace all place-holders for the required_if rule.
in
ReplacesAttributes at line 512
protected string
replaceRequiredIfAccepted(string $message, string $attribute, string $rule, array $parameters)
Replace all place-holders for the required_if_accepted rule.
in
ReplacesAttributes at line 524
protected string
replaceRequiredIfDeclined(string $message, string $attribute, string $rule, array $parameters)
Replace all place-holders for the required_if_declined rule.
in
ReplacesAttributes at line 534
protected string
replaceRequiredUnless(string $message, string $attribute, string $rule, array $parameters)
Replace all place-holders for the required_unless rule.
in
ReplacesAttributes at line 563
protected string
replaceProhibitedIf(string $message, string $attribute, string $rule, array $parameters)
Replace all place-holders for the prohibited_if rule.
in
ReplacesAttributes at line 573
protected string
replaceProhibitedIfAccepted(string $message, string $attribute, string $rule, array $parameters)
Replace all place-holders for the prohibited_if_accepted rule.
in
ReplacesAttributes at line 583
protected string
replaceProhibitedIfDeclined(string $message, string $attribute, string $rule, array $parameters)
Replace all place-holders for the prohibited_if_declined rule.
in
ReplacesAttributes at line 593
protected string
replaceProhibitedUnless(string $message, string $attribute, string $rule, array $parameters)
Replace all place-holders for the prohibited_unless rule.
in
ReplacesAttributes at line 603
protected string
replaceProhibits(string $message, string $attribute, string $rule, array $parameters)
Replace all place-holders for the prohibited_with rule.
in
ReplacesAttributes at line 621
protected string
replaceSame(string $message, string $attribute, string $rule, array $parameters)
Replace all place-holders for the same rule.
in
ReplacesAttributes at line 633
protected string
replaceBefore(string $message, string $attribute, string $rule, array $parameters)
Replace all place-holders for the before rule.
in
ReplacesAttributes at line 647
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 657
protected string
replaceAfter(string $message, string $attribute, string $rule, array $parameters)
Replace all place-holders for the after rule.
in
ReplacesAttributes at line 667
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 677
protected string
replaceDateEquals(string $message, string $attribute, string $rule, array $parameters)
Replace all place-holders for the date_equals rule.
in
ReplacesAttributes at line 687
protected string
replaceDimensions(string $message, string $attribute, string $rule, array $parameters)
Replace all place-holders for the dimensions rule.
in
ReplacesAttributes at line 705
protected string
replaceEndsWith(string $message, string $attribute, string $rule, array $parameters)
Replace all place-holders for the ends_with rule.
in
ReplacesAttributes at line 715
protected string
replaceDoesntEndWith(string $message, string $attribute, string $rule, array $parameters)
Replace all place-holders for the doesnt_end_with rule.
in
ReplacesAttributes at line 725
protected string
replaceStartsWith(string $message, string $attribute, string $rule, array $parameters)
Replace all place-holders for the starts_with rule.
in
ReplacesAttributes at line 735
protected string
replaceDoesntStartWith(string $message, string $attribute, string $rule, array $parameters)
Replace all place-holders for the doesnt_start_with rule.
in
ReplacesAttributes at line 745
protected string
replaceDoesntContain(string $message, string $attribute, string $rule, array $parameters)
Replace all place-holders for the doesnt_contain 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 77
protected string|null
getInlineMessage(string $attribute, string $rule)
Get the proper inline error message for standard and size rules.
in
FormatsMessages at line 93
protected array|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 150
protected string
getCustomMessageFromTranslator(array|string $keys)
Get the custom error message from the translator.
in
FormatsMessages at line 183
protected string
getWildcardCustomMessages(array $messages, string $search, string $default)
Check the given messages for a wildcard key.
in
FormatsMessages at line 201
protected string
getWildcardMessagePattern(string $key, bool $multipleSegments = false)
Build a wildcard message pattern that preserves literal path segments.
in
FormatsMessages at line 222
protected string
getSizeMessage(string $attribute, string $rule)
Get the proper error message for an attribute and size rule.
in
FormatsMessages at line 239
protected string
getAttributeType(string $attribute)
Get the data type of the given attribute.
in
FormatsMessages at line 256
string
makeReplacements(string $message, string $attribute, string $rule, array $parameters)
Replace all error message place-holders with actual values.
Attribute paths and dependent field parameters retain their encoded literal dots and asterisks until display or delivery to a registered custom replacer.
in
FormatsMessages at line 287
string
getDisplayableAttribute(string $attribute)
Get the displayable name of the attribute.
in
FormatsMessages at line 329
protected string|null
getAttributeFromTranslations(string $name)
Get the given attribute from the attribute translations.
in
FormatsMessages at line 341
protected string|null
getAttributeFromLocalArray(string $attribute, array|null $source = null)
Get the custom name for an attribute if it exists in the given array.
in
FormatsMessages at line 367
protected string
replaceAttributePlaceholder(string $message, string $value)
Replace the :attribute placeholder in the given message.
in
FormatsMessages at line 379
protected string
replaceIndexPlaceholder(string $message, string $attribute)
Replace the :index placeholder in the given message.
in
FormatsMessages at line 391
protected string
replacePositionPlaceholder(string $message, string $attribute)
Replace the :position placeholder in the given message.
in
FormatsMessages at line 404
protected string
replaceOrdinalPositionPlaceholder(string $message, string $attribute)
Replace the :ordinal-position placeholder in the given message.
in
FormatsMessages at line 421
protected string
replaceIndexOrPositionPlaceholder(string $message, string $attribute, string $placeholder, Closure|null $modifier = null)
Replace the :index or :position placeholder in the given message.
in
FormatsMessages at line 457
protected string
numberToIndexOrPositionWord(int $value)
Get the word for a index or position segment.
in
FormatsMessages at line 476
protected string
replaceInputPlaceholder(string $message, string $attribute)
Replace the :input placeholder in the given message.
in
FormatsMessages at line 494
string
getDisplayableValue(string $attribute, mixed $value)
Get the displayable name of the value.
in
FormatsMessages at line 526
protected array
getAttributeList(array $values)
Transform an array of attributes to their displayable form.
in
FormatsMessages at line 543
protected string|null
callReplacer(string $message, string $attribute, string $rule, array $parameters, Validator $validator)
Call a custom validator message replacer.
in
FormatsMessages at line 560
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 49
bool
validateAccepted(string $attribute, mixed $value)
Validate that an attribute was "accepted".
This validation rule implies the attribute is "required".
in
ValidatesAttributes at line 59
bool
validateAcceptedIf(string $attribute, mixed $value, mixed $parameters)
Validate that an attribute was "accepted" when another attribute has a given value.
in
ValidatesAttributes at line 79
bool
validateDeclined(string $attribute, mixed $value)
Validate that an attribute was "declined".
This validation rule implies the attribute is "required".
in
ValidatesAttributes at line 89
bool
validateDeclinedIf(string $attribute, mixed $value, mixed $parameters)
Validate that an attribute was "declined" when another attribute has a given value.
in
ValidatesAttributes at line 107
bool
validateActiveUrl(string $attribute, mixed $value)
Validate that an attribute is an active URL.
in
ValidatesAttributes at line 131
protected array|false
getDnsRecords(string $hostname, int $type)
Get the DNS records for the given hostname.
in
ValidatesAttributes at line 150
bool
validateAscii(string $attribute, mixed $value)
Validate that an attribute is 7 bit ASCII.
in
ValidatesAttributes at line 158
bool
validateBase64(string $attribute, mixed $value)
Validate that an attribute is a valid Base64 string.
in
ValidatesAttributes at line 174
bool
validateBail()
"Break" on first validation fail.
Always returns true, just lets us put "bail" in rules.
in
ValidatesAttributes at line 184
bool
validateBefore(string $attribute, mixed $value, mixed $parameters)
Validate the date is before a given date.
in
ValidatesAttributes at line 196
bool
validateBeforeOrEqual(string $attribute, mixed $value, mixed $parameters)
Validate the date is before or equal a given date.
in
ValidatesAttributes at line 208
bool
validateAfter(string $attribute, mixed $value, mixed $parameters)
Validate the date is after a given date.
in
ValidatesAttributes at line 220
bool
validateAfterOrEqual(string $attribute, mixed $value, mixed $parameters)
Validate the date is equal or after a given date.
in
ValidatesAttributes at line 232
protected bool
compareDates(string $attribute, mixed $value, array $parameters, string $operator)
Compare a given date against another using an operator.
in
ValidatesAttributes at line 262
protected string|null
getDateFormat(string $attribute)
Get the date format for an attribute if it has one.
in
ValidatesAttributes at line 278
protected int|null
getDateTimestamp(mixed $value)
Get the date timestamp.
in
ValidatesAttributes at line 293
protected bool
checkDateTimeOrder(string $format, mixed $value, mixed $argument, string $operator)
Compare a date value with a literal or referenced field using the given format.
in
ValidatesAttributes at line 326
protected DateTimeInterface|null
getDateTimeWithOptionalFormat(string $format, mixed $value)
Get a DateTime instance from a supported value using the given format.
in
ValidatesAttributes at line 346
protected DateTimeInterface|null
getDateTime(DateTimeInterface|float|int|string $value)
Get a DateTime instance from a string with no format.
in
ValidatesAttributes at line 362
bool
validateAlpha(string $attribute, mixed $value, mixed $parameters)
Validate that an attribute contains only alphabetic characters.
If the 'ascii' option is passed, validate that an attribute contains only ascii alphabetic characters.
in
ValidatesAttributes at line 378
bool
validateAlphaDash(string $attribute, mixed $value, mixed $parameters)
Validate that an attribute contains only alpha-numeric characters, dashes, and underscores.
If the 'ascii' option is passed, validate that an attribute contains only ascii alpha-numeric characters, dashes, and underscores.
in
ValidatesAttributes at line 397
bool
validateAlphaNum(string $attribute, mixed $value, mixed $parameters)
Validate that an attribute contains only alpha-numeric characters.
If the 'ascii' option is passed, validate that an attribute contains only ascii alpha-numeric characters.
in
ValidatesAttributes at line 415
bool
validateArray(string $attribute, mixed $value, array $parameters = [])
Validate that an attribute is an array.
in
ValidatesAttributes at line 434
protected array
acceptedArrayKeys(array $parameters)
Get the accepted literal and encoded array keys.
in
ValidatesAttributes at line 447
bool
validateArrayKeys(string $attribute, mixed $value, array $parameters)
Validate that an array does not contain any keys other than the given keys.
in
ValidatesAttributes at line 461
bool
validateList(string $attribute, mixed $value)
Validate that an attribute is a list.
in
ValidatesAttributes at line 471
bool
validateRequiredArrayKeys(string $attribute, mixed $value, array $parameters)
Validate that an array has all of the given keys.
in
ValidatesAttributes at line 492
bool
validateBetween(string $attribute, mixed $value, array $parameters)
Validate the size of an attribute is between a set of values.
in
ValidatesAttributes at line 511
bool
validateBoolean(string $attribute, mixed $value, array $parameters)
Validate that an attribute is a boolean.
in
ValidatesAttributes at line 527
bool
validateConfirmed(string $attribute, mixed $value, mixed $parameters)
Validate that an attribute has a matching confirmation.
in
ValidatesAttributes at line 537
bool
validateContains(string $attribute, mixed $value, mixed $parameters)
Validate an attribute contains a list of values.
in
ValidatesAttributes at line 558
bool
validateDoesntContain(string $attribute, mixed $value, mixed $parameters)
Validate an attribute does not contain a list of values.
in
ValidatesAttributes at line 579
protected bool
validateCurrentPassword(string $attribute, mixed $value, mixed $parameters)
Validate that the password of the currently authenticated user matches the given value.
in
ValidatesAttributes at line 596
bool
validateDate(string $attribute, mixed $value)
Validate that an attribute is a valid date.
in
ValidatesAttributes at line 608
protected bool
isValidDate(mixed $value)
Determine if a value is a valid date.
Accepts DateTimeInterface instances, numeric timestamps, and string date representations. Validates via strtotime() and date_parse() + checkdate() to reject dates like February 30th.
in
ValidatesAttributes at line 632
bool
validateDateFormat(string $attribute, mixed $value, mixed $parameters)
Validate that an attribute matches a date format.
in
ValidatesAttributes at line 655
protected bool
matchesDateFormat(mixed $value, string $format)
Determine if a value matches a specific date format.
Creates a DateTime from the format and verifies round-trip formatting produces the same string. Catches ValueError for invalid format strings.
in
ValidatesAttributes at line 676
bool
validateDateEquals(string $attribute, mixed $value, mixed $parameters)
Validate that an attribute is equal to another date.
in
ValidatesAttributes at line 688
bool
validateDecimal(string $attribute, mixed $value, mixed $parameters)
Validate that an attribute has a given number of decimal places.
in
ValidatesAttributes at line 717
bool
validateDifferent(string $attribute, mixed $value, mixed $parameters)
Validate that an attribute is different from another attribute.
in
ValidatesAttributes at line 739
bool
validateDigits(string $attribute, mixed $value, mixed $parameters)
Validate that an attribute has a given number of digits.
in
ValidatesAttributes at line 753
bool
validateDigitsBetween(string $attribute, mixed $value, mixed $parameters)
Validate that an attribute is between a given number of digits.
in
ValidatesAttributes at line 772
bool
validateDimensions(string $attribute, mixed $value, mixed $parameters)
Validate the dimensions of an image matches the given values.
in
ValidatesAttributes at line 809
protected bool
failsBasicDimensionChecks(array $parameters, int $width, int $height)
Test if the given width and height fail any conditions.
in
ValidatesAttributes at line 822
protected bool
failsRatioCheck(array $parameters, int $width, int $height)
Determine if the given parameters fail a dimension ratio check.
in
ValidatesAttributes at line 881
bool
validateDistinct(string $attribute, mixed $value, mixed $parameters)
Validate an attribute is unique among other values.
in
ValidatesAttributes at line 947
protected string|null
getDistinctValueKey(mixed $value)
Identify values whose strict equality can be counted without comparing every sibling.
in
ValidatesAttributes at line 965
protected array
getDistinctValues(string $attribute)
Get the values to distinct between.
in
ValidatesAttributes at line 984
protected array
extractDistinctValues(string $attribute)
Extract the distinct values from the data.
in
ValidatesAttributes at line 1003
bool
validateEmail(string $attribute, mixed $value, mixed $parameters)
Validate that an attribute is a valid e-mail address.
in
ValidatesAttributes at line 1042
protected bool
isValidEmail(string $value)
Determine if a value is a valid email address using basic RFC validation.
Used by the inline check for the bare email rule token. The
parameterized form (email:rfc,dns,spoof,filter,...) stays in
validateEmail() and flows through the delegated path.
in
ValidatesAttributes at line 1060
bool
validateEncoding(string $attribute, mixed $value, array $parameters)
Validate the encoding of an attribute.
in
ValidatesAttributes at line 1082
bool
validateExists(string $attribute, mixed $value, mixed $parameters)
Validate the existence of an attribute value in a database table.
in
ValidatesAttributes at line 1122
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 1146
bool
validateUnique(string $attribute, mixed $value, mixed $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 1193
protected array
getUniqueIds(string|null $idColumn, array $parameters)
Get the excluded ID column and value for the unique rule.
in
ValidatesAttributes at line 1203
protected int|string|null
prepareUniqueId(mixed $id)
Prepare the given ID for querying.
in
ValidatesAttributes at line 1225
protected array
getUniqueExtra(array $parameters)
Get the extra conditions for a unique rule.
in
ValidatesAttributes at line 1239
array
parseTable(string $table)
Parse the connection / table for the unique / exists rules.
in
ValidatesAttributes at line 1267
bool|string
getQueryColumn(array $parameters, string $attribute)
Get the column name for an exists / unique query.
in
ValidatesAttributes at line 1277
string
guessColumnForQuery(string $attribute)
Guess the database column from the given attribute name.
in
ValidatesAttributes at line 1291
protected array
getExtraConditions(array $segments)
Get the extra conditions for a unique / exists rule.
in
ValidatesAttributes at line 1309
bool
validateExtensions(string $attribute, mixed $value, array $parameters)
Validate the extension of a file upload attribute is in a set of defined extensions.
in
ValidatesAttributes at line 1325
bool
validateFile(string $attribute, mixed $value)
Validate the given value is a valid file.
in
ValidatesAttributes at line 1333
bool
validateFilled(string $attribute, mixed $value)
Validate the given attribute is filled if it is present.
in
ValidatesAttributes at line 1347
bool
validateGt(string $attribute, mixed $value, mixed $parameters)
Validate that an attribute is greater than another attribute.
in
ValidatesAttributes at line 1393
bool
validateLt(string $attribute, mixed $value, mixed $parameters)
Validate that an attribute is less than another attribute.
in
ValidatesAttributes at line 1439
bool
validateGte(string $attribute, mixed $value, mixed $parameters)
Validate that an attribute is greater than or equal another attribute.
in
ValidatesAttributes at line 1485
bool
validateLte(string $attribute, mixed $value, mixed $parameters)
Validate that an attribute is less than or equal another attribute.
in
ValidatesAttributes at line 1529
bool
validateLowercase(string $attribute, mixed $value)
Validate that an attribute is lowercase.
in
ValidatesAttributes at line 1537
bool
validateUppercase(string $attribute, mixed $value)
Validate that an attribute is uppercase.
in
ValidatesAttributes at line 1545
bool
validateHexColor(string $attribute, mixed $value)
Validate that an attribute is a valid HEX color.
in
ValidatesAttributes at line 1556
bool
validateImage(string $attribute, mixed $value, array $parameters = [])
Validate the MIME type of a file is an image MIME type.
in
ValidatesAttributes at line 1572
bool
validateIn(string $attribute, mixed $value, mixed $parameters)
Validate an attribute is contained within a list of values.
in
ValidatesAttributes at line 1600
bool
validateInArray(string $attribute, mixed $value, mixed $parameters)
Validate that the values of an attribute are in another attribute.
in
ValidatesAttributes at line 1620
bool
validateInArrayKeys(string $attribute, mixed $value, array $parameters)
Validate that an array contains at least one of the given keys.
in
ValidatesAttributes at line 1645
bool
validateInteger(string $attribute, mixed $value, array $parameters = [])
Validate that an attribute is an integer.
in
ValidatesAttributes at line 1657
bool
validateIp(string $attribute, mixed $value)
Validate that an attribute is a valid IP.
in
ValidatesAttributes at line 1665
bool
validateIpv4(string $attribute, mixed $value)
Validate that an attribute is a valid IPv4.
in
ValidatesAttributes at line 1673
bool
validateIpv6(string $attribute, mixed $value)
Validate that an attribute is a valid IPv6.
in
ValidatesAttributes at line 1681
protected bool
isValidIp(string $value)
Determine if a value is a valid IP address (any version).
in
ValidatesAttributes at line 1689
protected bool
isValidIpv4(string $value)
Determine if a value is a valid IPv4 address.
in
ValidatesAttributes at line 1697
protected bool
isValidIpv6(string $value)
Determine if a value is a valid IPv6 address.
in
ValidatesAttributes at line 1705
bool
validateMacAddress(string $attribute, mixed $value)
Validate that an attribute is a valid MAC address.
in
ValidatesAttributes at line 1713
bool
validateJson(string $attribute, mixed $value)
Validate the attribute is a valid JSON string.
in
ValidatesAttributes at line 1727
bool
validateMax(string $attribute, mixed $value, mixed $parameters)
Validate the size of an attribute is less than or equal to a maximum value.
in
ValidatesAttributes at line 1747
bool
validateMaxDigits(string $attribute, mixed $value, mixed $parameters)
Validate that an attribute has a maximum number of digits.
in
ValidatesAttributes at line 1765
bool
validateMimes(string $attribute, mixed $value, mixed $parameters)
Validate the guessed extension of a file upload is in a set of file extensions.
in
ValidatesAttributes at line 1787
bool
validateMimetypes(string $attribute, mixed $value, mixed $parameters)
Validate the MIME type of a file upload attribute is in a set of MIME types.
in
ValidatesAttributes at line 1807
protected bool
shouldBlockPhpUpload(mixed $value, array $parameters)
Check if PHP uploads are explicitly allowed.
in
ValidatesAttributes at line 1834
bool
validateMin(string $attribute, mixed $value, mixed $parameters)
Validate the size of an attribute is greater than or equal to a minimum value.
in
ValidatesAttributes at line 1850
bool
validateMinDigits(string $attribute, mixed $value, mixed $parameters)
Validate that an attribute has a minimum number of digits.
in
ValidatesAttributes at line 1870
bool
validateMissing(mixed $attribute, mixed $value, array<int, int|string> $parameters)
Validate that an attribute is missing.
in
ValidatesAttributes at line 1880
bool
validateMissingIf(string $attribute, mixed $value, mixed $parameters)
Validate that an attribute is missing when another attribute has a given value.
in
ValidatesAttributes at line 1898
bool
validateMissingUnless(string $attribute, mixed $value, mixed $parameters)
Validate that an attribute is missing unless another attribute has a given value.
in
ValidatesAttributes at line 1916
bool
validateMissingWith(string $attribute, mixed $value, mixed $parameters)
Validate that an attribute is missing when any given attribute is present.
in
ValidatesAttributes at line 1932
bool
validateMissingWithAll(string $attribute, mixed $value, mixed $parameters)
Validate that an attribute is missing when all given attributes are present.
in
ValidatesAttributes at line 1948
bool
validateMultipleOf(string $attribute, mixed $value, mixed $parameters)
Validate the value of an attribute is a multiple of a given value.
in
ValidatesAttributes at line 1985
bool
validateNullable()
"Indicate" validation should pass if value is null.
Always returns true, just lets us put "nullable" in rules.
in
ValidatesAttributes at line 1995
bool
validateNotIn(string $attribute, mixed $value, mixed $parameters)
Validate an attribute is not contained within a list of values.
in
ValidatesAttributes at line 2005
bool
validateNumeric(string $attribute, mixed $value, array $parameters = [])
Validate that an attribute is numeric.
in
ValidatesAttributes at line 2017
bool
validatePresent(string $attribute, mixed $value)
Validate that an attribute exists even if not filled.
in
ValidatesAttributes at line 2027
bool
validatePresentIf(string $attribute, mixed $value, mixed $parameters)
Validate that an attribute is present when another attribute has a given value.
in
ValidatesAttributes at line 2045
bool
validatePresentUnless(string $attribute, mixed $value, mixed $parameters)
Validate that an attribute is present unless another attribute has a given value.
in
ValidatesAttributes at line 2063
bool
validatePresentWith(string $attribute, mixed $value, mixed $parameters)
Validate that an attribute is present when any given attribute is present.
in
ValidatesAttributes at line 2079
bool
validatePresentWithAll(string $attribute, mixed $value, mixed $parameters)
Validate that an attribute is present when all given attributes are present.
in
ValidatesAttributes at line 2095
bool
validateRegex(string $attribute, mixed $value, mixed $parameters)
Validate that an attribute passes a regular expression check.
in
ValidatesAttributes at line 2111
bool
validateNotRegex(string $attribute, mixed $value, mixed $parameters)
Validate that an attribute does not pass a regular expression check.
in
ValidatesAttributes at line 2125
bool
validateRequired(string $attribute, mixed $value)
Validate that a required attribute exists.
in
ValidatesAttributes at line 2146
bool
validateRequiredIf(string $attribute, mixed $value, mixed $parameters)
Validate that an attribute exists when another attribute has a given value.
in
ValidatesAttributes at line 2166
bool
validateRequiredIfAccepted(string $attribute, mixed $value, mixed $parameters)
Validate that an attribute exists when another attribute was "accepted".
in
ValidatesAttributes at line 2180
bool
validateRequiredIfDeclined(string $attribute, mixed $value, mixed $parameters)
Validate that an attribute exists when another attribute was "declined".
in
ValidatesAttributes at line 2194
bool
validateProhibited(string $attribute, mixed $value)
Validate that an attribute does not exist or is an empty string.
in
ValidatesAttributes at line 2202
bool
validateProhibitedIf(string $attribute, mixed $value, mixed $parameters)
Validate that an attribute does not exist when another attribute has a given value.
in
ValidatesAttributes at line 2218
bool
validateProhibitedIfAccepted(string $attribute, mixed $value, mixed $parameters)
Validate that an attribute does not exist when another attribute was "accepted".
in
ValidatesAttributes at line 2232
bool
validateProhibitedIfDeclined(string $attribute, mixed $value, mixed $parameters)
Validate that an attribute does not exist when another attribute was "declined".
in
ValidatesAttributes at line 2246
bool
validateProhibitedUnless(string $attribute, mixed $value, mixed $parameters)
Validate that an attribute does not exist unless another attribute has a given value.
in
ValidatesAttributes at line 2262
bool
validateProhibits(string $attribute, mixed $value, mixed $parameters)
Validate that other attributes do not exist when this attribute exists.
in
ValidatesAttributes at line 2278
bool
validateExclude()
Indicate that an attribute is excluded.
in
ValidatesAttributes at line 2286
bool
validateExcludeIf(string $attribute, mixed $value, mixed $parameters)
Indicate that an attribute should be excluded when another attribute has a given value.
in
ValidatesAttributes at line 2302
bool
validateExcludeUnless(string $attribute, mixed $value, mixed $parameters)
Indicate that an attribute should be excluded when another attribute does not have a given value.
in
ValidatesAttributes at line 2314
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 2330
bool
validateExcludeWith(string $attribute, mixed $value, mixed $parameters)
Indicate that an attribute should be excluded when another attribute presents.
in
ValidatesAttributes at line 2344
bool
validateExcludeWithout(string $attribute, mixed $value, mixed $parameters)
Indicate that an attribute should be excluded when another attribute is missing.
in
ValidatesAttributes at line 2360
array
parseDependentRuleParameters(array $parameters)
Prepare the values and the other value for validation.
in
ValidatesAttributes at line 2380
protected bool
shouldConvertToBoolean(string $parameter)
Check if parameter should be converted to boolean.
in
ValidatesAttributes at line 2388
protected array
convertValuesToBoolean(array $values)
Convert the given values to boolean if they are string "true" / "false".
in
ValidatesAttributes at line 2400
protected array
convertValuesToNull(array $values)
Convert the given values to null if they are string "null".
in
ValidatesAttributes at line 2410
bool
validateRequiredWith(string $attribute, mixed $value, mixed $parameters)
Validate that an attribute exists when any other attribute exists.
in
ValidatesAttributes at line 2422
bool
validateRequiredWithAll(string $attribute, mixed $value, mixed $parameters)
Validate that an attribute exists when all other attributes exist.
in
ValidatesAttributes at line 2434
bool
validateRequiredWithout(string $attribute, mixed $value, mixed $parameters)
Validate that an attribute exists when another attribute does not.
in
ValidatesAttributes at line 2446
bool
validateRequiredWithoutAll(string $attribute, mixed $value, mixed $parameters)
Validate that an attribute exists when all other attributes do not.
in
ValidatesAttributes at line 2458
protected bool
anyFailingRequired(array $attributes)
Determine if any of the given attributes fail the required test.
in
ValidatesAttributes at line 2473
protected bool
allFailingRequired(array $attributes)
Determine if all of the given attributes fail the required test.
in
ValidatesAttributes at line 2490
bool
validateSame(string $attribute, mixed $value, mixed $parameters)
Validate that two attributes match.
in
ValidatesAttributes at line 2504
bool
validateSize(string $attribute, mixed $value, mixed $parameters)
Validate the size of an attribute.
in
ValidatesAttributes at line 2520
bool
validateSometimes()
"Validate" optional attributes.
Always returns true, just lets us put sometimes in rules.
in
ValidatesAttributes at line 2530
bool
validateStartsWith(string $attribute, mixed $value, mixed $parameters)
Validate the attribute starts with a given substring.
in
ValidatesAttributes at line 2544
bool
validateDoesntStartWith(string $attribute, mixed $value, mixed $parameters)
Validate the attribute does not start with a given substring.
in
ValidatesAttributes at line 2558
bool
validateEndsWith(string $attribute, mixed $value, mixed $parameters)
Validate the attribute ends with a given substring.
in
ValidatesAttributes at line 2572
bool
validateDoesntEndWith(string $attribute, mixed $value, mixed $parameters)
Validate the attribute does not end with a given substring.
in
ValidatesAttributes at line 2584
bool
validateString(string $attribute, mixed $value)
Validate that an attribute is a string.
in
ValidatesAttributes at line 2594
bool
validateTimezone(string $attribute, mixed $value, array $parameters = [])
Validate that an attribute is a valid timezone.
in
ValidatesAttributes at line 2614
bool
validateUrl(string $attribute, mixed $value, array $parameters = [])
Validate that an attribute is a valid URL.
in
ValidatesAttributes at line 2622
bool
validateUlid(string $attribute, mixed $value)
Validate that an attribute is a valid ULID.
in
ValidatesAttributes at line 2630
protected bool
isValidUlid(string $value)
Determine if a value is a valid ULID.
in
ValidatesAttributes at line 2640
bool
validateUuid(string $attribute, mixed $value, mixed $parameters)
Validate that an attribute is a valid UUID.
in
ValidatesAttributes at line 2662
protected bool
isValidUuid(string $value)
Determine if a value is a valid UUID (any version).
Used by the inline check for the bare uuid rule token. The
parameterized form (uuid:4, uuid:max) stays in validateUuid()
and flows through the delegated path.
in
ValidatesAttributes at line 2670
protected float|int|string
getSize(string $attribute, mixed $value)
Get the size of an attribute.
in
ValidatesAttributes at line 2682
protected float|int|string
sizeOf(string $attribute, mixed $value, bool $numeric)
Compute the validation size from numeric semantics and runtime value shape.
in
ValidatesAttributes at line 2702
bool
isValidFileInstance(mixed $value)
Check that the given value is a valid file instance.
in
ValidatesAttributes at line 2716
protected bool
compare(mixed $first, mixed $second, string $operator)
Determine if a comparison passes between the given values.
in
ValidatesAttributes at line 2735
array|null
parseNamedParameters(array $parameters)
Parse named parameters to $key => $value items.
in
ValidatesAttributes at line 2751
void
requireParameterCount(int $count, array $parameters, string $rule)
Require a certain number of parameters to be present.
in
ValidatesAttributes at line 2761
protected bool
isSameType(mixed $first, mixed $second)
Check if the parameters are of the same type.
in
ValidatesAttributes at line 2769
protected void
shouldBeNumeric(string $attribute, string $rule)
Adds the existing rule to the numericRules array if the attribute's value is numeric.
in
ValidatesAttributes at line 2779
protected mixed
trim(mixed $value)
Trim the value if it is a string.
in
ValidatesAttributes at line 2787
protected mixed
ensureExponentWithinAllowedRange(string $attribute, mixed $value)
Ensure the exponent is within the allowed range.
in
PlanExecutor at line 64
protected void
executeCompiledPlans(array $compiledPlans, array $preExcludedAttributes)
Execute all compiled plans against the validation data.
Per-check fresh reads of $value and $exists match validateAttribute()'s per-rule getValue() call.
in
PlanExecutor at line 141
protected void
executeDelegatedPlans(array $compiledPlans)
Execute all-delegated plans for a Validator subclass.
in
PlanExecutor at line 171
protected bool
shouldSkipNonImplicitCheck(AttributePlan $plan, mixed $value, bool $exists)
Determine if a non-implicit check should be skipped.
in
PlanExecutor at line 181
protected bool
shouldFailInvalidUpload(string $attribute, mixed $value)
Determine if an invalid upload should fail before rule execution.
in
PlanExecutor at line 191
protected bool
canPreflightInline(InlineCheck $check, mixed $value)
Determine if an inline check is safe to repeat during presence preflight.
in
PlanExecutor at line 256
protected bool
executeInline(InlineCheck $check, mixed $value, string $attribute)
Execute an inline check against a value.
Dispatches via exhaustive match over CheckType — no default arm. Adding a CheckType case without a handler here fails PHPStan and throws UnhandledMatchError at runtime. Silent passes are impossible.
Each arm replicates the exact logic of the corresponding validate*() method in ValidatesAttributes, but without parameter parsing, attribute context lookups, or dynamic method dispatch.
at line 375
__construct(Translator $translator, array $data, array $rules, array $messages = [], array $attributes = [])
Create a new Validator instance.
at line 393
array
parseData(array $data)
Parse the data array, converting dots and asterisks.
at line 401
protected array
replacePlaceholders(array $data)
Replace the placeholders used in data keys.
at line 409
protected string
replacePlaceholderInString(string $value)
Replace the placeholders in the given string.
at line 417
protected array
replaceDotPlaceholderInParameters(array $parameters)
Replace each field parameter key placeholder.
at line 430
Validator
after(callable|string $callback)
Add an after validation callback.
at line 448
bool
passes()
Determine if the data passes the validation rules.
at line 514
protected array
compileRules()
Compile all attribute rules into AttributePlans.
For the base Validator class, rules are compiled with inlining and cached worker-lifetime. Subclasses compile everything as DelegatedCheck to preserve validate*() overrides.
at line 549
protected bool
compiledPlansUseDataMutatingRules()
Determine if any compiled check can mutate this validator's data.
at line 597
protected array
preEvaluateExclusions()
Pre-evaluate safe first-position exclusion checks.
at line 717
protected void
maybeBatchDatabaseChecks(DatabasePresenceVerifier $presenceVerifier, array $preExcludedAttributes, array $unresolvedExclusionAttributes)
Batch safe database-presence candidates by query shape.
at line 944
bool
fails()
Determine if the data fails the validation rules.
at line 958
mixed
whenPasses(callable $callback, callable|null $default = null)
Execute the callback if the data passes the validation rules.
at line 979
mixed
whenFails(callable $callback, callable|null $default = null)
Execute the callback if the data fails the validation rules.
at line 994
protected bool
shouldBeExcluded(string $attribute)
Determine if the attribute should be excluded.
at line 1025
protected void
removeAttribute(string $attribute)
Remove the given attribute.
at line 1036
array
validate()
Run the validator's rules against its data.
at line 1050
array
validateWithBag(string $errorBag)
Run the validator's rules against its data.
at line 1069
array|ValidatedInput
safe(array|null $keys = null)
Get a validated input container for the validated input.
at line 1081
array
validated()
Get the attributes and values that were validated.
at line 1124
protected array
parentRuleKeys()
Get the rule keys that have nested rules beneath them.
at line 1144
protected void
validateAttribute(string $attribute, array|object|string $rule)
Validate a given attribute against a rule.
at line 1197
protected bool
dependsOnOtherFields(object|string $rule)
Determine if the given rule depends on other fields.
at line 1207
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 1225
protected string
getPrimaryAttribute(string $attribute)
Get the primary attribute name.
For example, if "name.0" is given, "name.*" will be returned.
at line 1253
protected array
replaceFieldsInParameters(string $rule, array $parameters, array $keys)
Resolve field parameters without rewriting literal comparison or database values.
at line 1272
protected array
replaceDotInParameters(array $parameters)
Replace each escaped field parameter separator with its placeholder.
at line 1282
protected array
replaceAsterisksInParameters(array $parameters, array $keys)
Replace each field parameter which has asterisks with the given keys.
at line 1293
protected bool
isValidatable(object|string $rule, string $attribute, mixed $value)
Determine if the attribute is validatable.
at line 1308
protected bool
presentOrRuleIsImplicit(object|string $rule, string $attribute, mixed $value)
Determine if the field is present, or the rule implies required.
at line 1325
protected bool
isImplicit(object|string $rule)
Determine if a given rule implies the attribute is required.
at line 1334
protected bool
passesOptionalCheck(string $attribute)
Determine if the attribute passes any optional check.
at line 1354
protected bool
isNotNullIfMarkedAsNullable(object|string $rule, string $attribute)
Determine if the attribute fails the nullable check.
at line 1377
protected bool
hasNotFailedPreviousRuleIfPresenceRule(object|string $rule, string $attribute)
Determine if it's a necessary presence validation.
This is to avoid possible database type comparison errors.
at line 1387
protected void
validateUsingCustomRule(string $attribute, mixed $value, Rule $rule)
Validate an attribute using a custom rule object.
at line 1443
protected bool
shouldStopValidating(string $attribute)
Check if we should stop further validations on a given attribute.
at line 1469
void
addFailure(string $attribute, string $rule, array $parameters = [])
Add a failed rule and error message to the collection.
at line 1505
protected void
excludeAttribute(string $attribute)
Add the given attribute to the list of excluded attributes.
at line 1513
array
valid()
Return the data which was valid.
at line 1528
array
invalid()
Return the data which was invalid.
at line 1553
protected array
attributesThatHaveMessages()
Generate an array of all attributes that have messages.
at line 1565
array
failed()
Get the failed validation rules.
at line 1573
MessageBag
messages()
Get the message container for the validator.
at line 1585
MessageBag
errors()
An alternative more semantic shortcut to the message container.
at line 1593
MessageBag
getMessageBag()
Get the messages for the instance.
at line 1601
bool
hasRule(string $attribute, array|string $rules)
Determine if the given attribute has a rule in the given set.
at line 1609
protected array|null
getRule(string $attribute, array|string $rules)
Get a rule and its parameters for a given attribute.
at line 1631
array
attributes()
Get the data under validation.
at line 1639
array
getData()
Get the data under validation.
at line 1649
Validator
setData(array $data)
Set the data under validation.
at line 1661
mixed
getValue(string $attribute)
Get the value of a given attribute.
at line 1669
void
setValue(string $attribute, mixed $value)
Set the value of a given attribute.
at line 1677
array
getRules()
Get the validation rules.
at line 1685
array
getRulesWithoutPlaceholders()
Get the validation rules with key placeholders removed.
at line 1699
Validator
setRules(array $rules)
Set the validation rules.
at line 1727
Validator
retainRules(array $attributes)
Retain the selected rules from the graph prepared for the current data.
Retention applies only to the current prepared graph. Calling setData() rebuilds the complete original rule graph.
at line 1745
Validator
appendRules(array $rules)
Append new validation rules to the validator.
at line 1759
void
addRules(array $rules)
| internal |
Parse the given rules and merge them into current rules.
at line 1784
Validator
sometimes(array|string $attribute, array|object|string $rules, callable $callback)
Add conditions to a given field based on a Closure.
at line 1830
Validator
stopOnFirstFailure(bool $stopOnFirstFailure = true)
Instruct the validator to stop validating after the first rule failure.
at line 1840
void
addExtensions(array $extensions)
Register an array of custom validator extensions.
at line 1854
void
addImplicitExtensions(array $extensions)
Register an array of custom implicit validator extensions.
at line 1866
void
addDependentExtensions(array $extensions)
Register an array of custom dependent validator extensions.
at line 1878
void
addExtension(string $rule, Closure|string $extension)
Register a custom validator extension.
at line 1886
void
addImplicitExtension(string $rule, Closure|string $extension)
Register a custom implicit validator extension.
at line 1896
void
addDependentExtension(string $rule, Closure|string $extension)
Register a custom dependent validator extension.
at line 1906
void
addReplacers(array $replacers)
Register an array of custom validator message replacers.
at line 1920
void
addReplacer(string $rule, Closure|string $replacer)
Register a custom validator message replacer.
at line 1930
Validator
setCustomMessages(array $messages)
Set the custom messages for the validator.
at line 1942
Validator
setAttributeNames(array $attributes)
Set the custom attributes on the validator.
at line 1954
Validator
addCustomAttributes(array $attributes)
Add custom attributes to the validator.
at line 1966
Validator
setImplicitAttributesFormatter(callable|null $formatter = null)
Set the callback that used to format an implicit attribute.
at line 1978
Validator
setValueNames(array $values)
Set the custom values on the validator.
at line 1990
Validator
addCustomValues(array $customValues)
Add the custom values for the validator.
at line 2000
void
setFallbackMessages(array $messages)
Set the fallback messages for the validator.
at line 2010
PresenceVerifierInterface
getPresenceVerifier(string|null $connection = null)
Get the Presence Verifier implementation.
at line 2029
void
setPresenceVerifier(PresenceVerifierInterface $presenceVerifier)
Set the Presence Verifier implementation.
at line 2039
string|ValidationException
getException()
Get the exception to throw upon failed validation.
at line 2052
Validator
setException(string|Throwable $exception)
Set the exception to throw upon failed validation.
at line 2071
Validator
ensureExponentWithinAllowedRangeUsing(callable $callback)
Ensure exponents are within range using the given callback.
at line 2081
Translator
getTranslator()
Get the Translator implementation.
at line 2089
void
setTranslator(Translator $translator)
Set the Translator implementation.
at line 2097
void
setContainer(Container $container)
Set the IoC container instance.
at line 2105
protected bool|null
callExtension(string $rule, array $parameters)
Call a custom validator extension.
at line 2122
protected bool
callClassBasedExtension(string $callback, array $parameters)
Call a class based validator extension.
at line 2133
static protected string
encodeAttributeWithPlaceholder(string $attribute)
Encode the attribute with the placeholder hash.
at line 2141
static protected string
decodeAttributeWithPlaceholder(string $attribute)
Decode an attribute with a placeholder hash.
at line 2152
static void
fakeDnsLookups(bool $value = true)
Fake the DNS lookups performed by validation rules so they always succeed.
The setting persists for the worker lifetime; failing to reset it through Validator::flushState() can make later tests bypass real DNS validation.
at line 2161
static void
flushState()
Flush all static state.
at line 2173
mixed
__call(string $method, array $parameters)
Handle dynamic calls to class methods.