final class LegacyValidator extends Validator

Baseline validator using the pre-rewrite validateAttribute() loop AND the original O(n²) wildcard expansion.

Provides an accurate performance comparison against the full optimized path by reverting BOTH the execution model and the wildcard expansion.

Traits

Execute compiled AttributePlans against validation data.

Properties

protected Container|null $container

The container instance.

from  Validator
protected PresenceVerifierInterface|null $presenceVerifier

The Presence Verifier implementation.

from  Validator
protected array $failedRules

The failed validation rules.

from  Validator
protected array $excludeAttributes

Attributes that should be excluded from the validated data.

from  Validator
protected MessageBag|null $messages

The message bag instance.

from  Validator
protected array $data

The data under validation.

from  Validator
protected array $initialRules

The initial rules provided.

from  Validator
protected array $rules

The rules to be applied to the data.

from  Validator
protected array|object|string|null $currentRule

The current rule that is validating.

from  Validator
protected array $implicitAttributes

The array of wildcard attributes with their asterisks expanded.

from  Validator
protected Closure|null $implicitAttributesFormatter

The callback that should be used to format the attribute.

from  Validator
protected array $distinctValues

The cached data for the "distinct" rule.

from  Validator
protected AttributePlan> $compiledPlans

The compiled execution plans for the current passes() invocation.

from  Validator
protected PresenceVerifierInterface|null $originalPresenceVerifier

The original presence verifier, saved during batched DB checks.

from  Validator
protected array $after

All of the registered "after" callbacks.

from  Validator
array $customMessages

The array of custom error messages.

from  Validator
array $fallbackMessages

The array of fallback error messages.

from  Validator
array $customAttributes

The array of custom attribute names.

from  Validator
array $customValues

The array of custom displayable values.

from  Validator
protected bool $stopOnFirstFailure

Indicates if the validator should stop on the first rule failure.

from  Validator
bool $excludeUnvalidatedArrayKeys

Indicates that unvalidated array keys should be excluded, even if the parent array was validated.

from  Validator
array $extensions

All of the custom validator extensions.

from  Validator
array $replacers

All of the custom replacer extensions.

from  Validator
protected string[] $fileRules

The validation rules that may be applied to files.

from  Validator
protected string[] $implicitRules

The validation rules that imply the field is required.

from  Validator
protected string[] $dependentRules

The validation rules which depend on other fields as parameters.

from  Validator
protected string[] $excludeRules

The validation rules that can exclude an attribute.

from  Validator
protected string[] $sizeRules

The size related validation rules.

from  Validator
protected string[] $numericRules

The numeric related validation rules.

from  Validator
protected string[] $defaultNumericRules

The default numeric related validation rules.

from  Validator
static protected bool $fakeDnsLookups

Indicates if DNS lookups performed by validation rules should be faked to always succeed.

from  Validator
static protected null|array<string, true> $encodingNames

The lowercase names of the encodings supported by mbstring.

from  Validator
static protected null|array<string, true> $timezoneIdentifiers

The identifiers of every timezone.

from  Validator
protected ValidationException>|ValidationException $exception

The exception to throw upon failure.

from  Validator
protected Closure|null $ensureExponentWithinAllowedRangeUsing

The custom callback to determine if an exponent is within allowed range.

from  Validator

Methods

string
replaceAcceptedIf(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the accepted_if rule.

string
replaceDeclinedIf(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the declined_if rule.

string
replaceBetween(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the between rule.

string
replaceDateFormat(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the date_format rule.

string
replaceDecimal(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the decimal rule.

string
replaceDifferent(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the different rule.

string
replaceDigits(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the digits rule.

string
replaceDigitsBetween(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the digits (between) rule.

string
replaceEncoding(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the encoding rule.

string
replaceExtensions(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the extensions rule.

string
replaceMin(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the min rule.

string
replaceMinDigits(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the min digits rule.

string
replaceMax(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the max rule.

string
replaceMaxDigits(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the max digits rule.

string
replaceMissingIf(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the missing_if rule.

string
replaceMissingUnless(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the missing_unless rule.

string
replaceMissingWith(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the missing_with rule.

string
replaceMissingWithAll(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the missing_with_all rule.

string
replaceMultipleOf(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the multiple_of rule.

string
replaceIn(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the in rule.

string
replaceNotIn(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the not_in rule.

string
replaceInArray(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the in_array rule.

string
replaceInArrayKeys(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the in_array_keys rule.

string
replaceArrayKeys(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the array_keys rule.

string
replaceRequiredArrayKeys(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the required_array_keys rule.

string
replaceMimetypes(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the mimetypes rule.

string
replaceMimes(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the mimes rule.

string
replacePresentIf(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the present_if rule.

string
replacePresentUnless(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the present_unless rule.

string
replacePresentWith(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the present_with rule.

string
replacePresentWithAll(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the present_with_all rule.

string
replaceRequiredWith(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the required_with rule.

string
replaceRequiredWithAll(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the required_with_all rule.

string
replaceRequiredWithout(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the required_without rule.

string
replaceRequiredWithoutAll(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the required_without_all rule.

string
replaceSize(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the size rule.

string
replaceGt(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the gt rule.

string
replaceLt(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the lt rule.

string
replaceGte(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the gte rule.

string
replaceLte(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the lte rule.

string
replaceRequiredIf(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the required_if rule.

string
replaceRequiredIfAccepted(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the required_if_accepted rule.

string
replaceRequiredIfDeclined(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the required_if_declined rule.

string
replaceRequiredUnless(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the required_unless rule.

string
replaceProhibitedIf(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the prohibited_if rule.

string
replaceProhibitedIfAccepted(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the prohibited_if_accepted rule.

string
replaceProhibitedIfDeclined(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the prohibited_if_declined rule.

string
replaceProhibitedUnless(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the prohibited_unless rule.

string
replaceProhibits(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the prohibited_with rule.

string
replaceSame(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the same rule.

string
replaceBefore(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the before rule.

string
replaceBeforeOrEqual(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the before_or_equal rule.

string
replaceAfter(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the after rule.

string
replaceAfterOrEqual(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the after_or_equal rule.

string
replaceDateEquals(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the date_equals rule.

string
replaceDimensions(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the dimensions rule.

string
replaceEndsWith(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the ends_with rule.

string
replaceDoesntEndWith(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the doesnt_end_with rule.

string
replaceStartsWith(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the starts_with rule.

string
replaceDoesntStartWith(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the doesnt_start_with rule.

string
replaceDoesntContain(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the doesnt_contain rule.

string
getMessage(string $attribute, string $rule)

Get the validation message for an attribute and rule.

string|null
getInlineMessage(string $attribute, string $rule)

Get the proper inline error message for standard and size rules.

array|string|null
getFromLocalArray(string $attribute, string $lowerRule, array|null $source = null)

Get the inline message for a rule if it exists.

string
getCustomMessageFromTranslator(array|string $keys)

Get the custom error message from the translator.

string
getWildcardCustomMessages(array $messages, string $search, string $default)

Check the given messages for a wildcard key.

string
getWildcardMessagePattern(string $key, bool $multipleSegments = false)

Build a wildcard message pattern that preserves literal path segments.

string
getSizeMessage(string $attribute, string $rule)

Get the proper error message for an attribute and size rule.

string
getAttributeType(string $attribute)

Get the data type of the given attribute.

string
makeReplacements(string $message, string $attribute, string $rule, array $parameters)

Replace all error message place-holders with actual values.

string
getDisplayableAttribute(string $attribute)

Get the displayable name of the attribute.

string|null
getAttributeFromTranslations(string $name)

Get the given attribute from the attribute translations.

string|null
getAttributeFromLocalArray(string $attribute, array|null $source = null)

Get the custom name for an attribute if it exists in the given array.

string
replaceAttributePlaceholder(string $message, string $value)

Replace the :attribute placeholder in the given message.

string
replaceIndexPlaceholder(string $message, string $attribute)

Replace the :index placeholder in the given message.

string
replacePositionPlaceholder(string $message, string $attribute)

Replace the :position placeholder in the given message.

string
replaceOrdinalPositionPlaceholder(string $message, string $attribute)

Replace the :ordinal-position placeholder in the given message.

string
replaceIndexOrPositionPlaceholder(string $message, string $attribute, string $placeholder, Closure|null $modifier = null)

Replace the :index or :position placeholder in the given message.

string
numberToIndexOrPositionWord(int $value)

Get the word for a index or position segment.

string
replaceInputPlaceholder(string $message, string $attribute)

Replace the :input placeholder in the given message.

string
getDisplayableValue(string $attribute, mixed $value)

Get the displayable name of the value.

array
getAttributeList(array $values)

Transform an array of attributes to their displayable form.

string|null
callReplacer(string $message, string $attribute, string $rule, array $parameters, Validator $validator)

Call a custom validator message replacer.

string
callClassBasedReplacer(string $callback, string $message, string $attribute, string $rule, array $parameters, Validator $validator)

Call a class based validator message replacer.

bool
validateAccepted(string $attribute, mixed $value)

Validate that an attribute was "accepted".

bool
validateAcceptedIf(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute was "accepted" when another attribute has a given value.

bool
validateDeclined(string $attribute, mixed $value)

Validate that an attribute was "declined".

bool
validateDeclinedIf(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute was "declined" when another attribute has a given value.

bool
validateActiveUrl(string $attribute, mixed $value)

Validate that an attribute is an active URL.

array|false
getDnsRecords(string $hostname, int $type)

Get the DNS records for the given hostname.

bool
validateAscii(string $attribute, mixed $value)

Validate that an attribute is 7 bit ASCII.

bool
validateBase64(string $attribute, mixed $value)

Validate that an attribute is a valid Base64 string.

bool
validateBail()

"Break" on first validation fail.

bool
validateBefore(string $attribute, mixed $value, mixed $parameters)

Validate the date is before a given date.

bool
validateBeforeOrEqual(string $attribute, mixed $value, mixed $parameters)

Validate the date is before or equal a given date.

bool
validateAfter(string $attribute, mixed $value, mixed $parameters)

Validate the date is after a given date.

bool
validateAfterOrEqual(string $attribute, mixed $value, mixed $parameters)

Validate the date is equal or after a given date.

bool
compareDates(string $attribute, mixed $value, array $parameters, string $operator)

Compare a given date against another using an operator.

string|null
getDateFormat(string $attribute)

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

int|null
getDateTimestamp(mixed $value)

Get the date timestamp.

bool
checkDateTimeOrder(string $format, mixed $value, mixed $argument, string $operator)

Compare a date value with a literal or referenced field using the given format.

getDateTimeWithOptionalFormat(string $format, mixed $value)

Get a DateTime instance from a supported value using the given format.

getDateTime(DateTimeInterface|float|int|string $value)

Get a DateTime instance from a string with no format.

bool
validateAlpha(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute contains only alphabetic characters.

bool
validateAlphaDash(string $attribute, mixed $value, mixed $parameters)

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

bool
validateAlphaNum(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute contains only alpha-numeric characters.

bool
validateArray(string $attribute, mixed $value, array $parameters = [])

Validate that an attribute is an array.

array
acceptedArrayKeys(array $parameters)

Get the accepted literal and encoded array keys.

bool
validateArrayKeys(string $attribute, mixed $value, array $parameters)

Validate that an array does not contain any keys other than the given keys.

bool
validateList(string $attribute, mixed $value)

Validate that an attribute is a list.

bool
validateRequiredArrayKeys(string $attribute, mixed $value, array $parameters)

Validate that an array has all of the given keys.

bool
validateBetween(string $attribute, mixed $value, array $parameters)

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

bool
validateBoolean(string $attribute, mixed $value, array $parameters)

Validate that an attribute is a boolean.

bool
validateConfirmed(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute has a matching confirmation.

bool
validateContains(string $attribute, mixed $value, mixed $parameters)

Validate an attribute contains a list of values.

bool
validateDoesntContain(string $attribute, mixed $value, mixed $parameters)

Validate an attribute does not contain a list of values.

bool
validateCurrentPassword(string $attribute, mixed $value, mixed $parameters)

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

bool
validateDate(string $attribute, mixed $value)

Validate that an attribute is a valid date.

bool
isValidDate(mixed $value)

Determine if a value is a valid date.

bool
validateDateFormat(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute matches a date format.

bool
matchesDateFormat(mixed $value, string $format)

Determine if a value matches a specific date format.

bool
validateDateEquals(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute is equal to another date.

bool
validateDecimal(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute has a given number of decimal places.

bool
validateDifferent(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute is different from another attribute.

bool
validateDigits(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute has a given number of digits.

bool
validateDigitsBetween(string $attribute, mixed $value, mixed $parameters)

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

bool
validateDimensions(string $attribute, mixed $value, mixed $parameters)

Validate the dimensions of an image matches the given values.

bool
failsBasicDimensionChecks(array $parameters, int $width, int $height)

Test if the given width and height fail any conditions.

bool
failsRatioCheck(array $parameters, int $width, int $height)

Determine if the given parameters fail a dimension ratio check.

bool
validateDistinct(string $attribute, mixed $value, mixed $parameters)

Validate an attribute is unique among other values.

array
getDistinctValues(string $attribute)

Get the values to distinct between.

array
extractDistinctValues(string $attribute)

Extract the distinct values from the data.

bool
validateEmail(string $attribute, mixed $value, mixed $parameters)

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

bool
isValidEmail(string $value)

Determine if a value is a valid email address using basic RFC validation.

bool
validateEncoding(string $attribute, mixed $value, array $parameters)

Validate the encoding of an attribute.

bool
validateExists(string $attribute, mixed $value, mixed $parameters)

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

int
getExistCount(mixed $connection, string $table, string $column, mixed $value, array $parameters)

Get the number of records that exist in storage.

bool
validateUnique(string $attribute, mixed $value, mixed $parameters)

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

array
getUniqueIds(string|null $idColumn, array $parameters)

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

int|string|null
prepareUniqueId(mixed $id)

Prepare the given ID for querying.

array
getUniqueExtra(array $parameters)

Get the extra conditions for a unique rule.

array
parseTable(string $table)

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

bool|string
getQueryColumn(array $parameters, string $attribute)

Get the column name for an exists / unique query.

string
guessColumnForQuery(string $attribute)

Guess the database column from the given attribute name.

array
getExtraConditions(array $segments)

Get the extra conditions for a unique / exists rule.

bool
validateExtensions(string $attribute, mixed $value, array $parameters)

Validate the extension of a file upload attribute is in a set of defined extensions.

bool
validateFile(string $attribute, mixed $value)

Validate the given value is a valid file.

bool
validateFilled(string $attribute, mixed $value)

Validate the given attribute is filled if it is present.

bool
validateGt(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute is greater than another attribute.

bool
validateLt(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute is less than another attribute.

bool
validateGte(string $attribute, mixed $value, mixed $parameters)

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

bool
validateLte(string $attribute, mixed $value, mixed $parameters)

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

bool
validateLowercase(string $attribute, mixed $value)

Validate that an attribute is lowercase.

bool
validateUppercase(string $attribute, mixed $value)

Validate that an attribute is uppercase.

bool
validateHexColor(string $attribute, mixed $value)

Validate that an attribute is a valid HEX color.

bool
validateImage(string $attribute, mixed $value, array $parameters = [])

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

bool
validateIn(string $attribute, mixed $value, mixed $parameters)

Validate an attribute is contained within a list of values.

bool
validateInArray(string $attribute, mixed $value, mixed $parameters)

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

bool
validateInArrayKeys(string $attribute, mixed $value, array $parameters)

Validate that an array contains at least one of the given keys.

bool
validateInteger(string $attribute, mixed $value, array $parameters = [])

Validate that an attribute is an integer.

bool
validateIp(string $attribute, mixed $value)

Validate that an attribute is a valid IP.

bool
validateIpv4(string $attribute, mixed $value)

Validate that an attribute is a valid IPv4.

bool
validateIpv6(string $attribute, mixed $value)

Validate that an attribute is a valid IPv6.

bool
isValidIp(string $value)

Determine if a value is a valid IP address (any version).

bool
isValidIpv4(string $value)

Determine if a value is a valid IPv4 address.

bool
isValidIpv6(string $value)

Determine if a value is a valid IPv6 address.

bool
validateMacAddress(string $attribute, mixed $value)

Validate that an attribute is a valid MAC address.

bool
validateJson(string $attribute, mixed $value)

Validate the attribute is a valid JSON string.

bool
validateMax(string $attribute, mixed $value, mixed $parameters)

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

bool
validateMaxDigits(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute has a maximum number of digits.

bool
validateMimes(string $attribute, mixed $value, mixed $parameters)

Validate the guessed extension of a file upload is in a set of file extensions.

bool
validateMimetypes(string $attribute, mixed $value, mixed $parameters)

Validate the MIME type of a file upload attribute is in a set of MIME types.

bool
shouldBlockPhpUpload(mixed $value, array $parameters)

Check if PHP uploads are explicitly allowed.

bool
validateMin(string $attribute, mixed $value, mixed $parameters)

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

bool
validateMinDigits(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute has a minimum number of digits.

bool
validateMissing(mixed $attribute, mixed $value, array<int, int|string> $parameters)

Validate that an attribute is missing.

bool
validateMissingIf(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute is missing when another attribute has a given value.

bool
validateMissingUnless(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute is missing unless another attribute has a given value.

bool
validateMissingWith(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute is missing when any given attribute is present.

bool
validateMissingWithAll(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute is missing when all given attributes are present.

bool
validateMultipleOf(string $attribute, mixed $value, mixed $parameters)

Validate the value of an attribute is a multiple of a given value.

bool
isMultipleOf(mixed $value, mixed $divisor)

Determine if a value is an exact multiple of a divisor.

bool
validateNullable()

"Indicate" validation should pass if value is null.

bool
validateNotIn(string $attribute, mixed $value, mixed $parameters)

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

bool
validateNumeric(string $attribute, mixed $value, array $parameters = [])

Validate that an attribute is numeric.

bool
validatePresent(string $attribute, mixed $value)

Validate that an attribute exists even if not filled.

bool
validatePresentIf(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute is present when another attribute has a given value.

bool
validatePresentUnless(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute is present unless another attribute has a given value.

bool
validatePresentWith(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute is present when any given attribute is present.

bool
validatePresentWithAll(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute is present when all given attributes are present.

bool
validateRegex(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute passes a regular expression check.

bool
validateNotRegex(string $attribute, mixed $value, mixed $parameters)

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

bool
validateRequired(string $attribute, mixed $value)

Validate that a required attribute exists.

bool
validateRequiredIf(string $attribute, mixed $value, mixed $parameters)

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

bool
validateRequiredIfAccepted(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute exists when another attribute was "accepted".

bool
validateRequiredIfDeclined(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute exists when another attribute was "declined".

bool
validateProhibited(string $attribute, mixed $value)

Validate that an attribute does not exist or is an empty string.

bool
validateProhibitedIf(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute does not exist when another attribute has a given value.

bool
validateProhibitedIfAccepted(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute does not exist when another attribute was "accepted".

bool
validateProhibitedIfDeclined(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute does not exist when another attribute was "declined".

bool
validateProhibitedUnless(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute does not exist unless another attribute has a given value.

bool
validateProhibits(string $attribute, mixed $value, mixed $parameters)

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

bool
validateExclude()

Indicate that an attribute is excluded.

bool
validateExcludeIf(string $attribute, mixed $value, mixed $parameters)

Indicate that an attribute should be excluded when another attribute has a given value.

bool
validateExcludeUnless(string $attribute, mixed $value, mixed $parameters)

Indicate that an attribute should be excluded when another attribute does not have a given value.

bool
validateRequiredUnless(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute exists when another attribute does not have a given value.

bool
validateExcludeWith(string $attribute, mixed $value, mixed $parameters)

Indicate that an attribute should be excluded when another attribute presents.

bool
validateExcludeWithout(string $attribute, mixed $value, mixed $parameters)

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

array
parseDependentRuleParameters(array $parameters)

Prepare the values and the other value for validation.

bool
shouldConvertToBoolean(string $parameter)

Check if parameter should be converted to boolean.

array
convertValuesToBoolean(array $values)

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

array
convertValuesToNull(array $values)

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

bool
validateRequiredWith(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute exists when any other attribute exists.

bool
validateRequiredWithAll(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute exists when all other attributes exist.

bool
validateRequiredWithout(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute exists when another attribute does not.

bool
validateRequiredWithoutAll(string $attribute, mixed $value, mixed $parameters)

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

bool
anyFailingRequired(array $attributes)

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

bool
allFailingRequired(array $attributes)

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

bool
validateSame(string $attribute, mixed $value, mixed $parameters)

Validate that two attributes match.

bool
validateSize(string $attribute, mixed $value, mixed $parameters)

Validate the size of an attribute.

bool
validateSometimes()

"Validate" optional attributes.

bool
validateStartsWith(string $attribute, mixed $value, mixed $parameters)

Validate the attribute starts with a given substring.

bool
validateDoesntStartWith(string $attribute, mixed $value, mixed $parameters)

Validate the attribute does not start with a given substring.

bool
validateEndsWith(string $attribute, mixed $value, mixed $parameters)

Validate the attribute ends with a given substring.

bool
validateDoesntEndWith(string $attribute, mixed $value, mixed $parameters)

Validate the attribute does not end with a given substring.

bool
validateString(string $attribute, mixed $value)

Validate that an attribute is a string.

bool
validateTimezone(string $attribute, mixed $value, array $parameters = [])

Validate that an attribute is a valid timezone.

bool
validateUrl(string $attribute, mixed $value, array $parameters = [])

Validate that an attribute is a valid URL.

bool
validateUlid(string $attribute, mixed $value)

Validate that an attribute is a valid ULID.

bool
isValidUlid(string $value)

Determine if a value is a valid ULID.

bool
validateUuid(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute is a valid UUID.

bool
isValidUuid(string $value)

Determine if a value is a valid UUID (any version).

float|int|string
getSize(string $attribute, mixed $value)

Get the size of an attribute.

float|int|string
sizeOf(string $attribute, mixed $value, bool $numeric)

Compute the validation size from numeric semantics and runtime value shape.

bool
isValidFileInstance(mixed $value)

Check that the given value is a valid file instance.

bool
compare(mixed $first, mixed $second, string $operator)

Determine if a comparison passes between the given values.

array|null
parseNamedParameters(array $parameters)

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

void
requireParameterCount(int $count, array $parameters, string $rule)

Require a certain number of parameters to be present.

bool
isSameType(mixed $first, mixed $second)

Check if the parameters are of the same type.

void
shouldBeNumeric(string $attribute, string $rule)

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

mixed
trim(mixed $value)

Trim the value if it is a string.

mixed
ensureExponentWithinAllowedRange(string $attribute, mixed $value)

Ensure the exponent is within the allowed range.

void
executeCompiledPlans(array $compiledPlans, array $preExcludedAttributes)

Execute all compiled plans against the validation data.

void
executeDelegatedPlans(array $compiledPlans)

Execute all-delegated plans for a Validator subclass.

bool
shouldSkipNonImplicitCheck(AttributePlan $plan, mixed $value, bool $exists)

Determine if a non-implicit check should be skipped.

bool
shouldFailInvalidUpload(string $attribute, mixed $value)

Determine if an invalid upload should fail before rule execution.

bool
canPreflightInline(InlineCheck $check, mixed $value)

Determine if an inline check is safe to repeat during presence preflight.

bool
executeInline(InlineCheck $check, mixed $value, string $attribute)

Execute an inline check against a value.

__construct(Translator $translator, array $data, array $rules, array $messages = [], array $attributes = [])

Create a new Validator instance.

array
parseData(array $data)

Parse the data array, converting dots and asterisks.

array
replacePlaceholders(array $data)

Replace the placeholders used in data keys.

string
replacePlaceholderInString(string $value)

Replace the placeholders in the given string.

array
replaceDotPlaceholderInParameters(array $parameters)

Replace each field parameter key placeholder.

after(callable|string $callback)

Add an after validation callback.

bool
passes()

Determine if the data passes the validation rules using the legacy path.

array
compileRules()

Compile all attribute rules into AttributePlans.

bool
compiledPlansUseDataMutatingRules()

Determine if any compiled check can mutate this validator's data.

array
preEvaluateExclusions()

Pre-evaluate safe first-position exclusion checks.

void
maybeBatchDatabaseChecks(DatabasePresenceVerifier $presenceVerifier, array $preExcludedAttributes, array $unresolvedExclusionAttributes)

Batch safe database-presence candidates by query shape.

bool
fails()

Determine if the data fails the validation rules.

mixed
whenPasses(callable $callback, callable|null $default = null)

Execute the callback if the data passes the validation rules.

mixed
whenFails(callable $callback, callable|null $default = null)

Execute the callback if the data fails the validation rules.

bool
shouldBeExcluded(string $attribute)

Determine if the attribute should be excluded.

void
removeAttribute(string $attribute)

Remove the given attribute.

array
validate()

Run the validator's rules against its data.

array
validateWithBag(string $errorBag)

Run the validator's rules against its data.

safe(array|null $keys = null)

Get a validated input container for the validated input.

array
validated()

Get the attributes and values that were validated.

void
validateAttribute(string $attribute, array|object|string $rule)

Validate a given attribute against a rule.

bool
dependsOnOtherFields(object|string $rule)

Determine if the given rule depends on other fields.

array
getExplicitKeys(string $attribute)

Get the explicit keys from an attribute flattened with dot notation.

string
getPrimaryAttribute(string $attribute)

Get the primary attribute name.

array
replaceDotInParameters(array $parameters)

Replace each escaped field parameter separator with its placeholder.

array
replaceAsterisksInParameters(array $parameters, array $keys)

Replace each field parameter which has asterisks with the given keys.

bool
isValidatable(object|string $rule, string $attribute, mixed $value)

Determine if the attribute is validatable.

bool
presentOrRuleIsImplicit(object|string $rule, string $attribute, mixed $value)

Determine if the field is present, or the rule implies required.

bool
isImplicit(object|string $rule)

Determine if a given rule implies the attribute is required.

bool
passesOptionalCheck(string $attribute)

Determine if the attribute passes any optional check.

bool
isNotNullIfMarkedAsNullable(object|string $rule, string $attribute)

Determine if the attribute fails the nullable check.

bool
hasNotFailedPreviousRuleIfPresenceRule(object|string $rule, string $attribute)

Determine if it's a necessary presence validation.

void
validateUsingCustomRule(string $attribute, mixed $value, Rule $rule)

Validate an attribute using a custom rule object.

bool
shouldStopValidating(string $attribute)

Check if we should stop further validations on a given attribute.

void
addFailure(string $attribute, string $rule, array $parameters = [])

Add a failed rule and error message to the collection.

void
excludeAttribute(string $attribute)

Add the given attribute to the list of excluded attributes.

array
valid()

Return the data which was valid.

array
invalid()

Return the data which was invalid.

array
attributesThatHaveMessages()

Generate an array of all attributes that have messages.

array
failed()

Get the failed validation rules.

messages()

Get the message container for the validator.

errors()

An alternative more semantic shortcut to the message container.

getMessageBag()

Get the messages for the instance.

bool
hasRule(string $attribute, array|string $rules)

Determine if the given attribute has a rule in the given set.

array|null
getRule(string $attribute, array|string $rules)

Get a rule and its parameters for a given attribute.

array
attributes()

Get the data under validation.

array
getData()

Get the data under validation.

setData(array $data)

Set the data under validation.

mixed
getValue(string $attribute)

Get the value of a given attribute.

void
setValue(string $attribute, mixed $value)

Set the value of a given attribute.

array
getRules()

Get the validation rules.

array
getRulesWithoutPlaceholders()

Get the validation rules with key placeholders removed.

setRules(array $rules)

Set the validation rules.

retainRules(array $attributes)

Retain the selected rules from the graph prepared for the current data.

appendRules(array $rules)

Append new validation rules to the validator.

void
addRules(array $rules)

Override addRules to use the legacy O(n²) wildcard expansion parser.

sometimes(array|string $attribute, array|string $rules, callable $callback)

Add conditions to a given field based on a Closure.

stopOnFirstFailure(bool $stopOnFirstFailure = true)

Instruct the validator to stop validating after the first rule failure.

void
addExtensions(array $extensions)

Register an array of custom validator extensions.

void
addImplicitExtensions(array $extensions)

Register an array of custom implicit validator extensions.

void
addDependentExtensions(array $extensions)

Register an array of custom dependent validator extensions.

void
addExtension(string $rule, Closure|string $extension)

Register a custom validator extension.

void
addImplicitExtension(string $rule, Closure|string $extension)

Register a custom implicit validator extension.

void
addDependentExtension(string $rule, Closure|string $extension)

Register a custom dependent validator extension.

void
addReplacers(array $replacers)

Register an array of custom validator message replacers.

void
addReplacer(string $rule, Closure|string $replacer)

Register a custom validator message replacer.

setCustomMessages(array $messages)

Set the custom messages for the validator.

setAttributeNames(array $attributes)

Set the custom attributes on the validator.

addCustomAttributes(array $attributes)

Add custom attributes to the validator.

setImplicitAttributesFormatter(callable|null $formatter = null)

Set the callback that used to format an implicit attribute.

setValueNames(array $values)

Set the custom values on the validator.

addCustomValues(array $customValues)

Add the custom values for the validator.

void
setFallbackMessages(array $messages)

Set the fallback messages for the validator.

getPresenceVerifier(string|null $connection = null)

Get the Presence Verifier implementation.

void
setPresenceVerifier(PresenceVerifierInterface $presenceVerifier)

Set the Presence Verifier implementation.

getException()

Get the exception to throw upon failed validation.

setException(string|Throwable $exception)

Set the exception to throw upon failed validation.

ensureExponentWithinAllowedRangeUsing(callable $callback)

Ensure exponents are within range using the given callback.

getTranslator()

Get the Translator implementation.

void
setTranslator(Translator $translator)

Set the Translator implementation.

void
setContainer(Container $container)

Set the IoC container instance.

bool|null
callExtension(string $rule, array $parameters)

Call a custom validator extension.

bool
callClassBasedExtension(string $callback, array $parameters)

Call a class based validator extension.

static string
encodeAttributeWithPlaceholder(string $attribute)

Encode the attribute with the placeholder hash.

static string
decodeAttributeWithPlaceholder(string $attribute)

Decode an attribute with a placeholder hash.

static void
fakeDnsLookups(bool $value = true)

Fake the DNS lookups performed by validation rules so they always succeed.

static void
flushState()

Flush all static state.

mixed
__call(string $method, array $parameters)

Handle dynamic calls to class methods.

Details

in ReplacesAttributes at line 17
protected string replaceAcceptedIf(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the accepted_if rule.

Parameters

string $message
string $attribute
string $rule
array $parameters

Return Value

string

in ReplacesAttributes at line 31
protected string replaceDeclinedIf(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the declined_if rule.

Parameters

string $message
string $attribute
string $rule
array $parameters

Return Value

string

in ReplacesAttributes at line 41
protected string replaceBetween(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the between rule.

Parameters

string $message
string $attribute
string $rule
array $parameters

Return Value

string

in ReplacesAttributes at line 51
protected string replaceDateFormat(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the date_format rule.

Parameters

string $message
string $attribute
string $rule
array $parameters

Return Value

string

in ReplacesAttributes at line 61
protected string replaceDecimal(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the decimal rule.

Parameters

string $message
string $attribute
string $rule
array $parameters

Return Value

string

in ReplacesAttributes at line 77
protected string replaceDifferent(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the different rule.

Parameters

string $message
string $attribute
string $rule
array $parameters

Return Value

string

in ReplacesAttributes at line 87
protected string replaceDigits(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the digits rule.

Parameters

string $message
string $attribute
string $rule
array $parameters

Return Value

string

in ReplacesAttributes at line 97
protected string replaceDigitsBetween(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the digits (between) rule.

Parameters

string $message
string $attribute
string $rule
array $parameters

Return Value

string

in ReplacesAttributes at line 107
protected string replaceEncoding(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the encoding rule.

Parameters

string $message
string $attribute
string $rule
array $parameters

Return Value

string

in ReplacesAttributes at line 117
protected string replaceExtensions(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the extensions rule.

Parameters

string $message
string $attribute
string $rule
array $parameters

Return Value

string

in ReplacesAttributes at line 127
protected string replaceMin(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the min rule.

Parameters

string $message
string $attribute
string $rule
array $parameters

Return Value

string

in ReplacesAttributes at line 137
protected string replaceMinDigits(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the min digits rule.

Parameters

string $message
string $attribute
string $rule
array $parameters

Return Value

string

in ReplacesAttributes at line 147
protected string replaceMax(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the max rule.

Parameters

string $message
string $attribute
string $rule
array $parameters

Return Value

string

in ReplacesAttributes at line 157
protected string replaceMaxDigits(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the max digits rule.

Parameters

string $message
string $attribute
string $rule
array $parameters

Return Value

string

in ReplacesAttributes at line 167
protected string replaceMissingIf(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the missing_if rule.

Parameters

string $message
string $attribute
string $rule
array $parameters

Return Value

string

in ReplacesAttributes at line 177
protected string replaceMissingUnless(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the missing_unless rule.

Parameters

string $message
string $attribute
string $rule
array $parameters

Return Value

string

in ReplacesAttributes at line 190
protected string replaceMissingWith(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the missing_with rule.

Parameters

string $message
string $attribute
string $rule
array $parameters

Return Value

string

in ReplacesAttributes at line 208
protected string replaceMissingWithAll(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the missing_with_all rule.

Parameters

string $message
string $attribute
string $rule
array $parameters

Return Value

string

in ReplacesAttributes at line 218
protected string replaceMultipleOf(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the multiple_of rule.

Parameters

string $message
string $attribute
string $rule
array $parameters

Return Value

string

in ReplacesAttributes at line 228
protected string replaceIn(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the in rule.

Parameters

string $message
string $attribute
string $rule
array $parameters

Return Value

string

in ReplacesAttributes at line 250
protected string replaceNotIn(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the not_in rule.

Parameters

string $message
string $attribute
string $rule
array $parameters

Return Value

string

in ReplacesAttributes at line 260
protected string replaceInArray(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the in_array rule.

Parameters

string $message
string $attribute
string $rule
array $parameters

Return Value

string

in ReplacesAttributes at line 272
protected string replaceInArrayKeys(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the in_array_keys rule.

Parameters

string $message
string $attribute
string $rule
array $parameters

Return Value

string

in ReplacesAttributes at line 282
protected string replaceArrayKeys(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the array_keys rule.

Parameters

string $message
string $attribute
string $rule
array $parameters

Return Value

string

in ReplacesAttributes at line 305
protected string replaceRequiredArrayKeys(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the required_array_keys rule.

Parameters

string $message
string $attribute
string $rule
array $parameters

Return Value

string

in ReplacesAttributes at line 315
protected string replaceMimetypes(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the mimetypes rule.

Parameters

string $message
string $attribute
string $rule
array $parameters

Return Value

string

in ReplacesAttributes at line 325
protected string replaceMimes(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the mimes rule.

Parameters

string $message
string $attribute
string $rule
array $parameters

Return Value

string

in ReplacesAttributes at line 335
protected string replacePresentIf(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the present_if rule.

Parameters

string $message
string $attribute
string $rule
array $parameters

Return Value

string

in ReplacesAttributes at line 345
protected string replacePresentUnless(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the present_unless rule.

Parameters

string $message
string $attribute
string $rule
array $parameters

Return Value

string

in ReplacesAttributes at line 355
protected string replacePresentWith(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the present_with rule.

Parameters

string $message
string $attribute
string $rule
array $parameters

Return Value

string

in ReplacesAttributes at line 373
protected string replacePresentWithAll(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the present_with_all rule.

Parameters

string $message
string $attribute
string $rule
array $parameters

Return Value

string

in ReplacesAttributes at line 383
protected string replaceRequiredWith(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the required_with rule.

Parameters

string $message
string $attribute
string $rule
array $parameters

Return Value

string

in ReplacesAttributes at line 401
protected string replaceRequiredWithAll(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the required_with_all rule.

Parameters

string $message
string $attribute
string $rule
array $parameters

Return Value

string

in ReplacesAttributes at line 411
protected string replaceRequiredWithout(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the required_without rule.

Parameters

string $message
string $attribute
string $rule
array $parameters

Return Value

string

in ReplacesAttributes at line 421
protected string replaceRequiredWithoutAll(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the required_without_all rule.

Parameters

string $message
string $attribute
string $rule
array $parameters

Return Value

string

in ReplacesAttributes at line 431
protected string replaceSize(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the size rule.

Parameters

string $message
string $attribute
string $rule
array $parameters

Return Value

string

in ReplacesAttributes at line 441
protected string replaceGt(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the gt rule.

Parameters

string $message
string $attribute
string $rule
array $parameters

Return Value

string

in ReplacesAttributes at line 455
protected string replaceLt(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the lt rule.

Parameters

string $message
string $attribute
string $rule
array $parameters

Return Value

string

in ReplacesAttributes at line 465
protected string replaceGte(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the gte rule.

Parameters

string $message
string $attribute
string $rule
array $parameters

Return Value

string

in ReplacesAttributes at line 475
protected string replaceLte(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the lte rule.

Parameters

string $message
string $attribute
string $rule
array $parameters

Return Value

string

in ReplacesAttributes at line 485
protected string replaceRequiredIf(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the required_if rule.

Parameters

string $message
string $attribute
string $rule
array $parameters

Return Value

string

in ReplacesAttributes at line 495
protected string replaceRequiredIfAccepted(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the required_if_accepted rule.

Parameters

string $message
string $attribute
string $rule
array $parameters

Return Value

string

in ReplacesAttributes at line 507
protected string replaceRequiredIfDeclined(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the required_if_declined rule.

Parameters

string $message
string $attribute
string $rule
array $parameters

Return Value

string

in ReplacesAttributes at line 517
protected string replaceRequiredUnless(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the required_unless rule.

Parameters

string $message
string $attribute
string $rule
array $parameters

Return Value

string

in ReplacesAttributes at line 546
protected string replaceProhibitedIf(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the prohibited_if rule.

Parameters

string $message
string $attribute
string $rule
array $parameters

Return Value

string

in ReplacesAttributes at line 556
protected string replaceProhibitedIfAccepted(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the prohibited_if_accepted rule.

Parameters

string $message
string $attribute
string $rule
array $parameters

Return Value

string

in ReplacesAttributes at line 566
protected string replaceProhibitedIfDeclined(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the prohibited_if_declined rule.

Parameters

string $message
string $attribute
string $rule
array $parameters

Return Value

string

in ReplacesAttributes at line 576
protected string replaceProhibitedUnless(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the prohibited_unless rule.

Parameters

string $message
string $attribute
string $rule
array $parameters

Return Value

string

in ReplacesAttributes at line 586
protected string replaceProhibits(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the prohibited_with rule.

Parameters

string $message
string $attribute
string $rule
array $parameters

Return Value

string

in ReplacesAttributes at line 604
protected string replaceSame(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the same rule.

Parameters

string $message
string $attribute
string $rule
array $parameters

Return Value

string

in ReplacesAttributes at line 616
protected string replaceBefore(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the before rule.

Parameters

string $message
string $attribute
string $rule
array $parameters

Return Value

string

in ReplacesAttributes at line 630
protected string replaceBeforeOrEqual(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the before_or_equal rule.

Parameters

string $message
string $attribute
string $rule
array $parameters

Return Value

string

in ReplacesAttributes at line 640
protected string replaceAfter(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the after rule.

Parameters

string $message
string $attribute
string $rule
array $parameters

Return Value

string

in ReplacesAttributes at line 650
protected string replaceAfterOrEqual(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the after_or_equal rule.

Parameters

string $message
string $attribute
string $rule
array $parameters

Return Value

string

in ReplacesAttributes at line 660
protected string replaceDateEquals(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the date_equals rule.

Parameters

string $message
string $attribute
string $rule
array $parameters

Return Value

string

in ReplacesAttributes at line 670
protected string replaceDimensions(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the dimensions rule.

Parameters

string $message
string $attribute
string $rule
array $parameters

Return Value

string

in ReplacesAttributes at line 688
protected string replaceEndsWith(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the ends_with rule.

Parameters

string $message
string $attribute
string $rule
array $parameters

Return Value

string

in ReplacesAttributes at line 698
protected string replaceDoesntEndWith(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the doesnt_end_with rule.

Parameters

string $message
string $attribute
string $rule
array $parameters

Return Value

string

in ReplacesAttributes at line 708
protected string replaceStartsWith(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the starts_with rule.

Parameters

string $message
string $attribute
string $rule
array $parameters

Return Value

string

in ReplacesAttributes at line 718
protected string replaceDoesntStartWith(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the doesnt_start_with rule.

Parameters

string $message
string $attribute
string $rule
array $parameters

Return Value

string

in ReplacesAttributes at line 728
protected string replaceDoesntContain(string $message, string $attribute, string $rule, array $parameters)

Replace all place-holders for the doesnt_contain rule.

Parameters

string $message
string $attribute
string $rule
array $parameters

Return Value

string

in FormatsMessages at line 21
protected string getMessage(string $attribute, string $rule)

Get the validation message for an attribute and rule.

Parameters

string $attribute
string $rule

Return Value

string

in FormatsMessages at line 77
protected string|null getInlineMessage(string $attribute, string $rule)

Get the proper inline error message for standard and size rules.

Parameters

string $attribute
string $rule

Return Value

string|null

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.

Parameters

string $attribute
string $lowerRule
array|null $source

Return Value

array|string|null

in FormatsMessages at line 150
protected string getCustomMessageFromTranslator(array|string $keys)

Get the custom error message from the translator.

Parameters

array|string $keys

Return Value

string

in FormatsMessages at line 183
protected string getWildcardCustomMessages(array $messages, string $search, string $default)

Check the given messages for a wildcard key.

Parameters

array $messages
string $search
string $default

Return Value

string

in FormatsMessages at line 201
protected string getWildcardMessagePattern(string $key, bool $multipleSegments = false)

Build a wildcard message pattern that preserves literal path segments.

Parameters

string $key
bool $multipleSegments

Return Value

string

in FormatsMessages at line 222
protected string getSizeMessage(string $attribute, string $rule)

Get the proper error message for an attribute and size rule.

Parameters

string $attribute
string $rule

Return Value

string

in FormatsMessages at line 239
protected string getAttributeType(string $attribute)

Get the data type of the given attribute.

Parameters

string $attribute

Return Value

string

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.

Parameters

string $message
string $attribute
string $rule
array $parameters

Return Value

string

in FormatsMessages at line 287
string getDisplayableAttribute(string $attribute)

Get the displayable name of the attribute.

Parameters

string $attribute

Return Value

string

in FormatsMessages at line 329
protected string|null getAttributeFromTranslations(string $name)

Get the given attribute from the attribute translations.

Parameters

string $name

Return Value

string|null

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.

Parameters

string $attribute
array|null $source

Return Value

string|null

in FormatsMessages at line 367
protected string replaceAttributePlaceholder(string $message, string $value)

Replace the :attribute placeholder in the given message.

Parameters

string $message
string $value

Return Value

string

in FormatsMessages at line 379
protected string replaceIndexPlaceholder(string $message, string $attribute)

Replace the :index placeholder in the given message.

Parameters

string $message
string $attribute

Return Value

string

in FormatsMessages at line 391
protected string replacePositionPlaceholder(string $message, string $attribute)

Replace the :position placeholder in the given message.

Parameters

string $message
string $attribute

Return Value

string

in FormatsMessages at line 404
protected string replaceOrdinalPositionPlaceholder(string $message, string $attribute)

Replace the :ordinal-position placeholder in the given message.

Parameters

string $message
string $attribute

Return Value

string

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.

Parameters

string $message
string $attribute
string $placeholder
Closure|null $modifier

Return Value

string

in FormatsMessages at line 457
protected string numberToIndexOrPositionWord(int $value)

Get the word for a index or position segment.

Parameters

int $value

Return Value

string

in FormatsMessages at line 476
protected string replaceInputPlaceholder(string $message, string $attribute)

Replace the :input placeholder in the given message.

Parameters

string $message
string $attribute

Return Value

string

in FormatsMessages at line 494
string getDisplayableValue(string $attribute, mixed $value)

Get the displayable name of the value.

Parameters

string $attribute
mixed $value

Return Value

string

in FormatsMessages at line 526
protected array getAttributeList(array $values)

Transform an array of attributes to their displayable form.

Parameters

array $values

Return Value

array

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.

Parameters

string $message
string $attribute
string $rule
array $parameters
Validator $validator

Return Value

string|null

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.

Parameters

string $callback
string $message
string $attribute
string $rule
array $parameters
Validator $validator

Return Value

string

bool validateAccepted(string $attribute, mixed $value)

Validate that an attribute was "accepted".

This validation rule implies the attribute is "required".

Parameters

string $attribute
mixed $value

Return Value

bool

bool validateAcceptedIf(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute was "accepted" when another attribute has a given value.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

bool validateDeclined(string $attribute, mixed $value)

Validate that an attribute was "declined".

This validation rule implies the attribute is "required".

Parameters

string $attribute
mixed $value

Return Value

bool

bool validateDeclinedIf(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute was "declined" when another attribute has a given value.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

in ValidatesAttributes at line 106
bool validateActiveUrl(string $attribute, mixed $value)

Validate that an attribute is an active URL.

Parameters

string $attribute
mixed $value

Return Value

bool

in ValidatesAttributes at line 130
protected array|false getDnsRecords(string $hostname, int $type)

Get the DNS records for the given hostname.

Parameters

string $hostname
int $type

Return Value

array|false

in ValidatesAttributes at line 149
bool validateAscii(string $attribute, mixed $value)

Validate that an attribute is 7 bit ASCII.

Parameters

string $attribute
mixed $value

Return Value

bool

in ValidatesAttributes at line 157
bool validateBase64(string $attribute, mixed $value)

Validate that an attribute is a valid Base64 string.

Parameters

string $attribute
mixed $value

Return Value

bool

in ValidatesAttributes at line 173
bool validateBail()

"Break" on first validation fail.

Always returns true, just lets us put "bail" in rules.

Return Value

bool

in ValidatesAttributes at line 183
bool validateBefore(string $attribute, mixed $value, mixed $parameters)

Validate the date is before a given date.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

in ValidatesAttributes at line 195
bool validateBeforeOrEqual(string $attribute, mixed $value, mixed $parameters)

Validate the date is before or equal a given date.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

in ValidatesAttributes at line 207
bool validateAfter(string $attribute, mixed $value, mixed $parameters)

Validate the date is after a given date.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

in ValidatesAttributes at line 219
bool validateAfterOrEqual(string $attribute, mixed $value, mixed $parameters)

Validate the date is equal or after a given date.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

in ValidatesAttributes at line 231
protected bool compareDates(string $attribute, mixed $value, array $parameters, string $operator)

Compare a given date against another using an operator.

Parameters

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

Return Value

bool

in ValidatesAttributes at line 261
protected string|null getDateFormat(string $attribute)

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

Parameters

string $attribute

Return Value

string|null

in ValidatesAttributes at line 277
protected int|null getDateTimestamp(mixed $value)

Get the date timestamp.

Parameters

mixed $value

Return Value

int|null

in ValidatesAttributes at line 292
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.

Parameters

string $format
mixed $value
mixed $argument
string $operator

Return Value

bool

in ValidatesAttributes at line 325
protected DateTimeInterface|null getDateTimeWithOptionalFormat(string $format, mixed $value)

Get a DateTime instance from a supported value using the given format.

Parameters

string $format
mixed $value

Return Value

DateTimeInterface|null

in ValidatesAttributes at line 345
protected DateTimeInterface|null getDateTime(DateTimeInterface|float|int|string $value)

Get a DateTime instance from a string with no format.

Parameters

DateTimeInterface|float|int|string $value

Return Value

DateTimeInterface|null

in ValidatesAttributes at line 361
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.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

in ValidatesAttributes at line 377
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.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

in ValidatesAttributes at line 396
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.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

in ValidatesAttributes at line 414
bool validateArray(string $attribute, mixed $value, array $parameters = [])

Validate that an attribute is an array.

Parameters

string $attribute
mixed $value
array $parameters

Return Value

bool

in ValidatesAttributes at line 433
protected array acceptedArrayKeys(array $parameters)

Get the accepted literal and encoded array keys.

Parameters

array $parameters

Return Value

array

in ValidatesAttributes at line 446
bool validateArrayKeys(string $attribute, mixed $value, array $parameters)

Validate that an array does not contain any keys other than the given keys.

Parameters

string $attribute
mixed $value
array $parameters

Return Value

bool

in ValidatesAttributes at line 460
bool validateList(string $attribute, mixed $value)

Validate that an attribute is a list.

Parameters

string $attribute
mixed $value

Return Value

bool

in ValidatesAttributes at line 470
bool validateRequiredArrayKeys(string $attribute, mixed $value, array $parameters)

Validate that an array has all of the given keys.

Parameters

string $attribute
mixed $value
array $parameters

Return Value

bool

in ValidatesAttributes at line 491
bool validateBetween(string $attribute, mixed $value, array $parameters)

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

Parameters

string $attribute
mixed $value
array $parameters

Return Value

bool

in ValidatesAttributes at line 510
bool validateBoolean(string $attribute, mixed $value, array $parameters)

Validate that an attribute is a boolean.

Parameters

string $attribute
mixed $value
array $parameters

Return Value

bool

in ValidatesAttributes at line 526
bool validateConfirmed(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute has a matching confirmation.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

in ValidatesAttributes at line 536
bool validateContains(string $attribute, mixed $value, mixed $parameters)

Validate an attribute contains a list of values.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

in ValidatesAttributes at line 557
bool validateDoesntContain(string $attribute, mixed $value, mixed $parameters)

Validate an attribute does not contain a list of values.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

in ValidatesAttributes at line 578
protected bool validateCurrentPassword(string $attribute, mixed $value, mixed $parameters)

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

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

in ValidatesAttributes at line 595
bool validateDate(string $attribute, mixed $value)

Validate that an attribute is a valid date.

Parameters

string $attribute
mixed $value

Return Value

bool

in ValidatesAttributes at line 607
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.

Parameters

mixed $value

Return Value

bool

in ValidatesAttributes at line 631
bool validateDateFormat(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute matches a date format.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

in ValidatesAttributes at line 654
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.

Parameters

mixed $value
string $format

Return Value

bool

in ValidatesAttributes at line 675
bool validateDateEquals(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute is equal to another date.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

in ValidatesAttributes at line 687
bool validateDecimal(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute has a given number of decimal places.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

in ValidatesAttributes at line 716
bool validateDifferent(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute is different from another attribute.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

in ValidatesAttributes at line 738
bool validateDigits(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute has a given number of digits.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

in ValidatesAttributes at line 752
bool validateDigitsBetween(string $attribute, mixed $value, mixed $parameters)

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

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

in ValidatesAttributes at line 771
bool validateDimensions(string $attribute, mixed $value, mixed $parameters)

Validate the dimensions of an image matches the given values.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

in ValidatesAttributes at line 808
protected bool failsBasicDimensionChecks(array $parameters, int $width, int $height)

Test if the given width and height fail any conditions.

Parameters

array $parameters
int $width
int $height

Return Value

bool

in ValidatesAttributes at line 821
protected bool failsRatioCheck(array $parameters, int $width, int $height)

Determine if the given parameters fail a dimension ratio check.

Parameters

array $parameters
int $width
int $height

Return Value

bool

in ValidatesAttributes at line 880
bool validateDistinct(string $attribute, mixed $value, mixed $parameters)

Validate an attribute is unique among other values.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

in ValidatesAttributes at line 900
protected array getDistinctValues(string $attribute)

Get the values to distinct between.

Parameters

string $attribute

Return Value

array

in ValidatesAttributes at line 919
protected array extractDistinctValues(string $attribute)

Extract the distinct values from the data.

Parameters

string $attribute

Return Value

array

in ValidatesAttributes at line 938
bool validateEmail(string $attribute, mixed $value, mixed $parameters)

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

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

in ValidatesAttributes at line 977
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.

Parameters

string $value

Return Value

bool

in ValidatesAttributes at line 995
bool validateEncoding(string $attribute, mixed $value, array $parameters)

Validate the encoding of an attribute.

Parameters

string $attribute
mixed $value
array $parameters

Return Value

bool

Exceptions

InvalidArgumentException

in ValidatesAttributes at line 1017
bool validateExists(string $attribute, mixed $value, mixed $parameters)

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

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

in ValidatesAttributes at line 1048
protected int getExistCount(mixed $connection, string $table, string $column, mixed $value, array $parameters)

Get the number of records that exist in storage.

Parameters

mixed $connection
string $table
string $column
mixed $value
array $parameters

Return Value

int

in ValidatesAttributes at line 1072
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.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

in ValidatesAttributes at line 1119
protected array getUniqueIds(string|null $idColumn, array $parameters)

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

Parameters

string|null $idColumn
array $parameters

Return Value

array

in ValidatesAttributes at line 1129
protected int|string|null prepareUniqueId(mixed $id)

Prepare the given ID for querying.

Parameters

mixed $id

Return Value

int|string|null

in ValidatesAttributes at line 1151
protected array getUniqueExtra(array $parameters)

Get the extra conditions for a unique rule.

Parameters

array $parameters

Return Value

array

in ValidatesAttributes at line 1165
array parseTable(string $table)

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

Parameters

string $table

Return Value

array

in ValidatesAttributes at line 1193
bool|string getQueryColumn(array $parameters, string $attribute)

Get the column name for an exists / unique query.

Parameters

array $parameters
string $attribute

Return Value

bool|string

in ValidatesAttributes at line 1203
string guessColumnForQuery(string $attribute)

Guess the database column from the given attribute name.

Parameters

string $attribute

Return Value

string

in ValidatesAttributes at line 1217
protected array getExtraConditions(array $segments)

Get the extra conditions for a unique / exists rule.

Parameters

array $segments

Return Value

array

in ValidatesAttributes at line 1235
bool validateExtensions(string $attribute, mixed $value, array $parameters)

Validate the extension of a file upload attribute is in a set of defined extensions.

Parameters

string $attribute
mixed $value
array $parameters

Return Value

bool

in ValidatesAttributes at line 1251
bool validateFile(string $attribute, mixed $value)

Validate the given value is a valid file.

Parameters

string $attribute
mixed $value

Return Value

bool

in ValidatesAttributes at line 1259
bool validateFilled(string $attribute, mixed $value)

Validate the given attribute is filled if it is present.

Parameters

string $attribute
mixed $value

Return Value

bool

in ValidatesAttributes at line 1273
bool validateGt(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute is greater than another attribute.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

in ValidatesAttributes at line 1317
bool validateLt(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute is less than another attribute.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

in ValidatesAttributes at line 1361
bool validateGte(string $attribute, mixed $value, mixed $parameters)

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

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

in ValidatesAttributes at line 1405
bool validateLte(string $attribute, mixed $value, mixed $parameters)

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

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

in ValidatesAttributes at line 1447
bool validateLowercase(string $attribute, mixed $value)

Validate that an attribute is lowercase.

Parameters

string $attribute
mixed $value

Return Value

bool

in ValidatesAttributes at line 1455
bool validateUppercase(string $attribute, mixed $value)

Validate that an attribute is uppercase.

Parameters

string $attribute
mixed $value

Return Value

bool

in ValidatesAttributes at line 1463
bool validateHexColor(string $attribute, mixed $value)

Validate that an attribute is a valid HEX color.

Parameters

string $attribute
mixed $value

Return Value

bool

in ValidatesAttributes at line 1474
bool validateImage(string $attribute, mixed $value, array $parameters = [])

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

Parameters

string $attribute
mixed $value
array $parameters

Return Value

bool

in ValidatesAttributes at line 1490
bool validateIn(string $attribute, mixed $value, mixed $parameters)

Validate an attribute is contained within a list of values.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

in ValidatesAttributes at line 1518
bool validateInArray(string $attribute, mixed $value, mixed $parameters)

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

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

in ValidatesAttributes at line 1538
bool validateInArrayKeys(string $attribute, mixed $value, array $parameters)

Validate that an array contains at least one of the given keys.

Parameters

string $attribute
mixed $value
array $parameters

Return Value

bool

in ValidatesAttributes at line 1563
bool validateInteger(string $attribute, mixed $value, array $parameters = [])

Validate that an attribute is an integer.

Parameters

string $attribute
mixed $value
array $parameters

Return Value

bool

in ValidatesAttributes at line 1575
bool validateIp(string $attribute, mixed $value)

Validate that an attribute is a valid IP.

Parameters

string $attribute
mixed $value

Return Value

bool

in ValidatesAttributes at line 1583
bool validateIpv4(string $attribute, mixed $value)

Validate that an attribute is a valid IPv4.

Parameters

string $attribute
mixed $value

Return Value

bool

in ValidatesAttributes at line 1591
bool validateIpv6(string $attribute, mixed $value)

Validate that an attribute is a valid IPv6.

Parameters

string $attribute
mixed $value

Return Value

bool

in ValidatesAttributes at line 1599
protected bool isValidIp(string $value)

Determine if a value is a valid IP address (any version).

Parameters

string $value

Return Value

bool

in ValidatesAttributes at line 1607
protected bool isValidIpv4(string $value)

Determine if a value is a valid IPv4 address.

Parameters

string $value

Return Value

bool

in ValidatesAttributes at line 1615
protected bool isValidIpv6(string $value)

Determine if a value is a valid IPv6 address.

Parameters

string $value

Return Value

bool

in ValidatesAttributes at line 1623
bool validateMacAddress(string $attribute, mixed $value)

Validate that an attribute is a valid MAC address.

Parameters

string $attribute
mixed $value

Return Value

bool

in ValidatesAttributes at line 1631
bool validateJson(string $attribute, mixed $value)

Validate the attribute is a valid JSON string.

Parameters

string $attribute
mixed $value

Return Value

bool

in ValidatesAttributes at line 1645
bool validateMax(string $attribute, mixed $value, mixed $parameters)

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

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

in ValidatesAttributes at line 1665
bool validateMaxDigits(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute has a maximum number of digits.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

in ValidatesAttributes at line 1683
bool validateMimes(string $attribute, mixed $value, mixed $parameters)

Validate the guessed extension of a file upload is in a set of file extensions.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

in ValidatesAttributes at line 1705
bool validateMimetypes(string $attribute, mixed $value, mixed $parameters)

Validate the MIME type of a file upload attribute is in a set of MIME types.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

in ValidatesAttributes at line 1725
protected bool shouldBlockPhpUpload(mixed $value, array $parameters)

Check if PHP uploads are explicitly allowed.

Parameters

mixed $value
array $parameters

Return Value

bool

in ValidatesAttributes at line 1752
bool validateMin(string $attribute, mixed $value, mixed $parameters)

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

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

in ValidatesAttributes at line 1768
bool validateMinDigits(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute has a minimum number of digits.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

in ValidatesAttributes at line 1788
bool validateMissing(mixed $attribute, mixed $value, array<int, int|string> $parameters)

Validate that an attribute is missing.

Parameters

mixed $attribute
mixed $value
array<int, int|string> $parameters

Return Value

bool

in ValidatesAttributes at line 1798
bool validateMissingIf(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute is missing when another attribute has a given value.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

in ValidatesAttributes at line 1816
bool validateMissingUnless(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute is missing unless another attribute has a given value.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

in ValidatesAttributes at line 1834
bool validateMissingWith(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute is missing when any given attribute is present.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

in ValidatesAttributes at line 1850
bool validateMissingWithAll(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute is missing when all given attributes are present.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

in ValidatesAttributes at line 1868
bool validateMultipleOf(string $attribute, mixed $value, mixed $parameters)

Validate the value of an attribute is a multiple of a given value.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

Exceptions

MathException

in ValidatesAttributes at line 1880
protected bool isMultipleOf(mixed $value, mixed $divisor)

Determine if a value is an exact multiple of a divisor.

Parameters

mixed $value
mixed $divisor

Return Value

bool

Exceptions

MathException

in ValidatesAttributes at line 1913
bool validateNullable()

"Indicate" validation should pass if value is null.

Always returns true, just lets us put "nullable" in rules.

Return Value

bool

in ValidatesAttributes at line 1923
bool validateNotIn(string $attribute, mixed $value, mixed $parameters)

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

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

in ValidatesAttributes at line 1933
bool validateNumeric(string $attribute, mixed $value, array $parameters = [])

Validate that an attribute is numeric.

Parameters

string $attribute
mixed $value
array $parameters

Return Value

bool

in ValidatesAttributes at line 1945
bool validatePresent(string $attribute, mixed $value)

Validate that an attribute exists even if not filled.

Parameters

string $attribute
mixed $value

Return Value

bool

in ValidatesAttributes at line 1955
bool validatePresentIf(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute is present when another attribute has a given value.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

in ValidatesAttributes at line 1973
bool validatePresentUnless(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute is present unless another attribute has a given value.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

in ValidatesAttributes at line 1991
bool validatePresentWith(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute is present when any given attribute is present.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

in ValidatesAttributes at line 2007
bool validatePresentWithAll(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute is present when all given attributes are present.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

in ValidatesAttributes at line 2023
bool validateRegex(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute passes a regular expression check.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

in ValidatesAttributes at line 2039
bool validateNotRegex(string $attribute, mixed $value, mixed $parameters)

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

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

in ValidatesAttributes at line 2053
bool validateRequired(string $attribute, mixed $value)

Validate that a required attribute exists.

Parameters

string $attribute
mixed $value

Return Value

bool

in ValidatesAttributes at line 2074
bool validateRequiredIf(string $attribute, mixed $value, mixed $parameters)

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

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

in ValidatesAttributes at line 2094
bool validateRequiredIfAccepted(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute exists when another attribute was "accepted".

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

in ValidatesAttributes at line 2108
bool validateRequiredIfDeclined(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute exists when another attribute was "declined".

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

in ValidatesAttributes at line 2122
bool validateProhibited(string $attribute, mixed $value)

Validate that an attribute does not exist or is an empty string.

Parameters

string $attribute
mixed $value

Return Value

bool

in ValidatesAttributes at line 2130
bool validateProhibitedIf(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute does not exist when another attribute has a given value.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

in ValidatesAttributes at line 2146
bool validateProhibitedIfAccepted(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute does not exist when another attribute was "accepted".

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

in ValidatesAttributes at line 2160
bool validateProhibitedIfDeclined(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute does not exist when another attribute was "declined".

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

in ValidatesAttributes at line 2174
bool validateProhibitedUnless(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute does not exist unless another attribute has a given value.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

in ValidatesAttributes at line 2190
bool validateProhibits(string $attribute, mixed $value, mixed $parameters)

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

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

in ValidatesAttributes at line 2206
bool validateExclude()

Indicate that an attribute is excluded.

Return Value

bool

in ValidatesAttributes at line 2214
bool validateExcludeIf(string $attribute, mixed $value, mixed $parameters)

Indicate that an attribute should be excluded when another attribute has a given value.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

in ValidatesAttributes at line 2230
bool validateExcludeUnless(string $attribute, mixed $value, mixed $parameters)

Indicate that an attribute should be excluded when another attribute does not have a given value.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

in ValidatesAttributes at line 2242
bool validateRequiredUnless(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute exists when another attribute does not have a given value.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

in ValidatesAttributes at line 2258
bool validateExcludeWith(string $attribute, mixed $value, mixed $parameters)

Indicate that an attribute should be excluded when another attribute presents.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

in ValidatesAttributes at line 2272
bool validateExcludeWithout(string $attribute, mixed $value, mixed $parameters)

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

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

in ValidatesAttributes at line 2288
array parseDependentRuleParameters(array $parameters)

Prepare the values and the other value for validation.

Parameters

array $parameters

Return Value

array

in ValidatesAttributes at line 2308
protected bool shouldConvertToBoolean(string $parameter)

Check if parameter should be converted to boolean.

Parameters

string $parameter

Return Value

bool

in ValidatesAttributes at line 2316
protected array convertValuesToBoolean(array $values)

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

Parameters

array $values

Return Value

array

in ValidatesAttributes at line 2328
protected array convertValuesToNull(array $values)

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

Parameters

array $values

Return Value

array

in ValidatesAttributes at line 2338
bool validateRequiredWith(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute exists when any other attribute exists.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

in ValidatesAttributes at line 2350
bool validateRequiredWithAll(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute exists when all other attributes exist.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

in ValidatesAttributes at line 2362
bool validateRequiredWithout(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute exists when another attribute does not.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

in ValidatesAttributes at line 2374
bool validateRequiredWithoutAll(string $attribute, mixed $value, mixed $parameters)

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

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

in ValidatesAttributes at line 2386
protected bool anyFailingRequired(array $attributes)

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

Parameters

array $attributes

Return Value

bool

in ValidatesAttributes at line 2401
protected bool allFailingRequired(array $attributes)

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

Parameters

array $attributes

Return Value

bool

in ValidatesAttributes at line 2418
bool validateSame(string $attribute, mixed $value, mixed $parameters)

Validate that two attributes match.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

in ValidatesAttributes at line 2432
bool validateSize(string $attribute, mixed $value, mixed $parameters)

Validate the size of an attribute.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

in ValidatesAttributes at line 2448
bool validateSometimes()

"Validate" optional attributes.

Always returns true, just lets us put sometimes in rules.

Return Value

bool

in ValidatesAttributes at line 2458
bool validateStartsWith(string $attribute, mixed $value, mixed $parameters)

Validate the attribute starts with a given substring.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

in ValidatesAttributes at line 2472
bool validateDoesntStartWith(string $attribute, mixed $value, mixed $parameters)

Validate the attribute does not start with a given substring.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

in ValidatesAttributes at line 2486
bool validateEndsWith(string $attribute, mixed $value, mixed $parameters)

Validate the attribute ends with a given substring.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

in ValidatesAttributes at line 2500
bool validateDoesntEndWith(string $attribute, mixed $value, mixed $parameters)

Validate the attribute does not end with a given substring.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

in ValidatesAttributes at line 2512
bool validateString(string $attribute, mixed $value)

Validate that an attribute is a string.

Parameters

string $attribute
mixed $value

Return Value

bool

in ValidatesAttributes at line 2522
bool validateTimezone(string $attribute, mixed $value, array $parameters = [])

Validate that an attribute is a valid timezone.

Parameters

string $attribute
mixed $value
array $parameters

Return Value

bool

in ValidatesAttributes at line 2542
bool validateUrl(string $attribute, mixed $value, array $parameters = [])

Validate that an attribute is a valid URL.

Parameters

string $attribute
mixed $value
array $parameters

Return Value

bool

in ValidatesAttributes at line 2550
bool validateUlid(string $attribute, mixed $value)

Validate that an attribute is a valid ULID.

Parameters

string $attribute
mixed $value

Return Value

bool

in ValidatesAttributes at line 2558
protected bool isValidUlid(string $value)

Determine if a value is a valid ULID.

Parameters

string $value

Return Value

bool

in ValidatesAttributes at line 2568
bool validateUuid(string $attribute, mixed $value, mixed $parameters)

Validate that an attribute is a valid UUID.

Parameters

string $attribute
mixed $value
mixed $parameters

Return Value

bool

in ValidatesAttributes at line 2590
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.

Parameters

string $value

Return Value

bool

in ValidatesAttributes at line 2598
protected float|int|string getSize(string $attribute, mixed $value)

Get the size of an attribute.

Parameters

string $attribute
mixed $value

Return Value

float|int|string

in ValidatesAttributes at line 2610
protected float|int|string sizeOf(string $attribute, mixed $value, bool $numeric)

Compute the validation size from numeric semantics and runtime value shape.

Parameters

string $attribute
mixed $value
bool $numeric

Return Value

float|int|string

in ValidatesAttributes at line 2630
bool isValidFileInstance(mixed $value)

Check that the given value is a valid file instance.

Parameters

mixed $value

Return Value

bool

in ValidatesAttributes at line 2644
protected bool compare(mixed $first, mixed $second, string $operator)

Determine if a comparison passes between the given values.

Parameters

mixed $first
mixed $second
string $operator

Return Value

bool

Exceptions

InvalidArgumentException

in ValidatesAttributes at line 2663
array|null parseNamedParameters(array $parameters)

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

Parameters

array $parameters

Return Value

array|null

in ValidatesAttributes at line 2679
void requireParameterCount(int $count, array $parameters, string $rule)

Require a certain number of parameters to be present.

Parameters

int $count
array $parameters
string $rule

Return Value

void

Exceptions

InvalidArgumentException

in ValidatesAttributes at line 2689
protected bool isSameType(mixed $first, mixed $second)

Check if the parameters are of the same type.

Parameters

mixed $first
mixed $second

Return Value

bool

in ValidatesAttributes at line 2697
protected void shouldBeNumeric(string $attribute, string $rule)

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

Parameters

string $attribute
string $rule

Return Value

void

in ValidatesAttributes at line 2707
protected mixed trim(mixed $value)

Trim the value if it is a string.

Parameters

mixed $value

Return Value

mixed

in ValidatesAttributes at line 2715
protected mixed ensureExponentWithinAllowedRange(string $attribute, mixed $value)

Ensure the exponent is within the allowed range.

Parameters

string $attribute
mixed $value

Return Value

mixed

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.

Parameters

array $compiledPlans
array $preExcludedAttributes

Return Value

void

in PlanExecutor at line 141
protected void executeDelegatedPlans(array $compiledPlans)

Execute all-delegated plans for a Validator subclass.

Parameters

array $compiledPlans

Return Value

void

in PlanExecutor at line 171
protected bool shouldSkipNonImplicitCheck(AttributePlan $plan, mixed $value, bool $exists)

Determine if a non-implicit check should be skipped.

Parameters

AttributePlan $plan
mixed $value
bool $exists

Return Value

bool

in PlanExecutor at line 181
protected bool shouldFailInvalidUpload(string $attribute, mixed $value)

Determine if an invalid upload should fail before rule execution.

Parameters

string $attribute
mixed $value

Return Value

bool

in PlanExecutor at line 191
protected bool canPreflightInline(InlineCheck $check, mixed $value)

Determine if an inline check is safe to repeat during presence preflight.

Parameters

InlineCheck $check
mixed $value

Return Value

bool

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.

Parameters

InlineCheck $check
mixed $value
string $attribute

Return Value

bool

in Validator at line 354
__construct(Translator $translator, array $data, array $rules, array $messages = [], array $attributes = [])

Create a new Validator instance.

Parameters

Translator $translator

the Translator implementation

array $data
array $rules
array $messages
array $attributes

in Validator at line 372
array parseData(array $data)

Parse the data array, converting dots and asterisks.

Parameters

array $data

Return Value

array

in Validator at line 380
protected array replacePlaceholders(array $data)

Replace the placeholders used in data keys.

Parameters

array $data

Return Value

array

in Validator at line 388
protected string replacePlaceholderInString(string $value)

Replace the placeholders in the given string.

Parameters

string $value

Return Value

string

in Validator at line 396
protected array replaceDotPlaceholderInParameters(array $parameters)

Replace each field parameter key placeholder.

Parameters

array $parameters

Return Value

array

in Validator at line 407
Validator after(callable|string $callback)

Add an after validation callback.

Parameters

callable|string $callback

Return Value

Validator

at line 413
bool passes()

Determine if the data passes the validation rules using the legacy path.

Return Value

bool

in Validator at line 491
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.

Return Value

array

in Validator at line 526
protected bool compiledPlansUseDataMutatingRules()

Determine if any compiled check can mutate this validator's data.

Return Value

bool

in Validator at line 574
protected array preEvaluateExclusions()

Pre-evaluate safe first-position exclusion checks.

Return Value

array

in Validator at line 698
protected void maybeBatchDatabaseChecks(DatabasePresenceVerifier $presenceVerifier, array $preExcludedAttributes, array $unresolvedExclusionAttributes)

Batch safe database-presence candidates by query shape.

Parameters

DatabasePresenceVerifier $presenceVerifier
array $preExcludedAttributes
array $unresolvedExclusionAttributes

Return Value

void

in Validator at line 925
bool fails()

Determine if the data fails the validation rules.

Return Value

bool

in Validator at line 939
mixed whenPasses(callable $callback, callable|null $default = null)

Execute the callback if the data passes the validation rules.

Parameters

callable $callback
callable|null $default

Return Value

mixed

in Validator at line 960
mixed whenFails(callable $callback, callable|null $default = null)

Execute the callback if the data fails the validation rules.

Parameters

callable $callback
callable|null $default

Return Value

mixed

in Validator at line 975
protected bool shouldBeExcluded(string $attribute)

Determine if the attribute should be excluded.

Parameters

string $attribute

Return Value

bool

in Validator at line 1017
protected void removeAttribute(string $attribute)

Remove the given attribute.

Parameters

string $attribute

Return Value

void

in Validator at line 1028
array validate()

Run the validator's rules against its data.

Return Value

array

Exceptions

ValidationException

in Validator at line 1042
array validateWithBag(string $errorBag)

Run the validator's rules against its data.

Parameters

string $errorBag

Return Value

array

Exceptions

ValidationException

in Validator at line 1061
array|ValidatedInput safe(array|null $keys = null)

Get a validated input container for the validated input.

Parameters

array|null $keys

Return Value

array|ValidatedInput

Exceptions

ValidationException

in Validator at line 1073
array validated()

Get the attributes and values that were validated.

Return Value

array

Exceptions

ValidationException

in Validator at line 1112
protected void validateAttribute(string $attribute, array|object|string $rule)

Validate a given attribute against a rule.

Parameters

string $attribute
array|object|string $rule

Return Value

void

in Validator at line 1169
protected bool dependsOnOtherFields(object|string $rule)

Determine if the given rule depends on other fields.

Parameters

object|string $rule

Return Value

bool

in Validator at line 1179
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'

Parameters

string $attribute

Return Value

array

in Validator at line 1197
protected string getPrimaryAttribute(string $attribute)

Get the primary attribute name.

For example, if "name.0" is given, "name.*" will be returned.

Parameters

string $attribute

Return Value

string

in Validator at line 1225
protected array replaceDotInParameters(array $parameters)

Replace each escaped field parameter separator with its placeholder.

Parameters

array $parameters

Return Value

array

in Validator at line 1235
protected array replaceAsterisksInParameters(array $parameters, array $keys)

Replace each field parameter which has asterisks with the given keys.

Parameters

array $parameters
array $keys

Return Value

array

in Validator at line 1245
protected bool isValidatable(object|string $rule, string $attribute, mixed $value)

Determine if the attribute is validatable.

Parameters

object|string $rule
string $attribute
mixed $value

Return Value

bool

in Validator at line 1260
protected bool presentOrRuleIsImplicit(object|string $rule, string $attribute, mixed $value)

Determine if the field is present, or the rule implies required.

Parameters

object|string $rule
string $attribute
mixed $value

Return Value

bool

in Validator at line 1277
protected bool isImplicit(object|string $rule)

Determine if a given rule implies the attribute is required.

Parameters

object|string $rule

Return Value

bool

in Validator at line 1286
protected bool passesOptionalCheck(string $attribute)

Determine if the attribute passes any optional check.

Parameters

string $attribute

Return Value

bool

in Validator at line 1306
protected bool isNotNullIfMarkedAsNullable(object|string $rule, string $attribute)

Determine if the attribute fails the nullable check.

Parameters

object|string $rule
string $attribute

Return Value

bool

in Validator at line 1329
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.

Parameters

object|string $rule
string $attribute

Return Value

bool

in Validator at line 1339
protected void validateUsingCustomRule(string $attribute, mixed $value, Rule $rule)

Validate an attribute using a custom rule object.

Parameters

string $attribute
mixed $value
Rule $rule

Return Value

void

in Validator at line 1395
protected bool shouldStopValidating(string $attribute)

Check if we should stop further validations on a given attribute.

Parameters

string $attribute

Return Value

bool

in Validator at line 1421
void addFailure(string $attribute, string $rule, array $parameters = [])

Add a failed rule and error message to the collection.

Parameters

string $attribute
string $rule
array $parameters

Return Value

void

in Validator at line 1457
protected void excludeAttribute(string $attribute)

Add the given attribute to the list of excluded attributes.

Parameters

string $attribute

Return Value

void

in Validator at line 1473
array valid()

Return the data which was valid.

Return Value

array

in Validator at line 1488
array invalid()

Return the data which was invalid.

Return Value

array

in Validator at line 1513
protected array attributesThatHaveMessages()

Generate an array of all attributes that have messages.

Return Value

array

in Validator at line 1525
array failed()

Get the failed validation rules.

Return Value

array

in Validator at line 1533
MessageBag messages()

Get the message container for the validator.

Return Value

MessageBag

in Validator at line 1545
MessageBag errors()

An alternative more semantic shortcut to the message container.

Return Value

MessageBag

in Validator at line 1553
MessageBag getMessageBag()

Get the messages for the instance.

Return Value

MessageBag

in Validator at line 1561
bool hasRule(string $attribute, array|string $rules)

Determine if the given attribute has a rule in the given set.

Parameters

string $attribute
array|string $rules

Return Value

bool

in Validator at line 1569
protected array|null getRule(string $attribute, array|string $rules)

Get a rule and its parameters for a given attribute.

Parameters

string $attribute
array|string $rules

Return Value

array|null

in Validator at line 1591
array attributes()

Get the data under validation.

Return Value

array

in Validator at line 1599
array getData()

Get the data under validation.

Return Value

array

in Validator at line 1607
Validator setData(array $data)

Set the data under validation.

Parameters

array $data

Return Value

Validator

in Validator at line 1619
mixed getValue(string $attribute)

Get the value of a given attribute.

Parameters

string $attribute

Return Value

mixed

in Validator at line 1627
void setValue(string $attribute, mixed $value)

Set the value of a given attribute.

Parameters

string $attribute
mixed $value

Return Value

void

in Validator at line 1635
array getRules()

Get the validation rules.

Return Value

array

in Validator at line 1643
array getRulesWithoutPlaceholders()

Get the validation rules with key placeholders removed.

Return Value

array

in Validator at line 1655
Validator setRules(array $rules)

Set the validation rules.

Parameters

array $rules

Return Value

Validator

in Validator at line 1682
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.

Parameters

array $attributes

Return Value

Validator

in Validator at line 1698
Validator appendRules(array $rules)

Append new validation rules to the validator.

Parameters

array $rules

Return Value

Validator

at line 395
void addRules(array $rules)

Override addRules to use the legacy O(n²) wildcard expansion parser.

Parameters

array $rules

Return Value

void

in Validator at line 1735
Validator sometimes(array|string $attribute, array|string $rules, callable $callback)

Add conditions to a given field based on a Closure.

Parameters

array|string $attribute
array|string $rules
callable $callback

Return Value

Validator

in Validator at line 1779
Validator stopOnFirstFailure(bool $stopOnFirstFailure = true)

Instruct the validator to stop validating after the first rule failure.

Parameters

bool $stopOnFirstFailure

Return Value

Validator

in Validator at line 1789
void addExtensions(array $extensions)

Register an array of custom validator extensions.

Parameters

array $extensions

Return Value

void

in Validator at line 1803
void addImplicitExtensions(array $extensions)

Register an array of custom implicit validator extensions.

Parameters

array $extensions

Return Value

void

in Validator at line 1815
void addDependentExtensions(array $extensions)

Register an array of custom dependent validator extensions.

Parameters

array $extensions

Return Value

void

in Validator at line 1827
void addExtension(string $rule, Closure|string $extension)

Register a custom validator extension.

Parameters

string $rule
Closure|string $extension

Return Value

void

in Validator at line 1835
void addImplicitExtension(string $rule, Closure|string $extension)

Register a custom implicit validator extension.

Parameters

string $rule
Closure|string $extension

Return Value

void

in Validator at line 1845
void addDependentExtension(string $rule, Closure|string $extension)

Register a custom dependent validator extension.

Parameters

string $rule
Closure|string $extension

Return Value

void

in Validator at line 1855
void addReplacers(array $replacers)

Register an array of custom validator message replacers.

Parameters

array $replacers

Return Value

void

in Validator at line 1869
void addReplacer(string $rule, Closure|string $replacer)

Register a custom validator message replacer.

Parameters

string $rule
Closure|string $replacer

Return Value

void

in Validator at line 1877
Validator setCustomMessages(array $messages)

Set the custom messages for the validator.

Parameters

array $messages

Return Value

Validator

in Validator at line 1887
Validator setAttributeNames(array $attributes)

Set the custom attributes on the validator.

Parameters

array $attributes

Return Value

Validator

in Validator at line 1897
Validator addCustomAttributes(array $attributes)

Add custom attributes to the validator.

Parameters

array $attributes

Return Value

Validator

in Validator at line 1907
Validator setImplicitAttributesFormatter(callable|null $formatter = null)

Set the callback that used to format an implicit attribute.

Parameters

callable|null $formatter

Return Value

Validator

in Validator at line 1917
Validator setValueNames(array $values)

Set the custom values on the validator.

Parameters

array $values

Return Value

Validator

in Validator at line 1927
Validator addCustomValues(array $customValues)

Add the custom values for the validator.

Parameters

array $customValues

Return Value

Validator

in Validator at line 1937
void setFallbackMessages(array $messages)

Set the fallback messages for the validator.

Parameters

array $messages

Return Value

void

in Validator at line 1947
PresenceVerifierInterface getPresenceVerifier(string|null $connection = null)

Get the Presence Verifier implementation.

Parameters

string|null $connection

Return Value

PresenceVerifierInterface

Exceptions

RuntimeException

in Validator at line 1966
void setPresenceVerifier(PresenceVerifierInterface $presenceVerifier)

Set the Presence Verifier implementation.

Parameters

PresenceVerifierInterface $presenceVerifier

Return Value

void

in Validator at line 1976
string|ValidationException getException()

Get the exception to throw upon failed validation.

Return Value

string|ValidationException

in Validator at line 1988
Validator setException(string|Throwable $exception)

Set the exception to throw upon failed validation.

Parameters

string|Throwable $exception

Return Value

Validator

Exceptions

InvalidArgumentException

in Validator at line 2006
Validator ensureExponentWithinAllowedRangeUsing(callable $callback)

Ensure exponents are within range using the given callback.

Parameters

callable $callback

Return Value

Validator

in Validator at line 2016
Translator getTranslator()

Get the Translator implementation.

Return Value

Translator

in Validator at line 2024
void setTranslator(Translator $translator)

Set the Translator implementation.

Parameters

Translator $translator

Return Value

void

in Validator at line 2032
void setContainer(Container $container)

Set the IoC container instance.

Parameters

Container $container

Return Value

void

in Validator at line 2040
protected bool|null callExtension(string $rule, array $parameters)

Call a custom validator extension.

Parameters

string $rule
array $parameters

Return Value

bool|null

in Validator at line 2057
protected bool callClassBasedExtension(string $callback, array $parameters)

Call a class based validator extension.

Parameters

string $callback
array $parameters

Return Value

bool

in Validator at line 2068
static protected string encodeAttributeWithPlaceholder(string $attribute)

Encode the attribute with the placeholder hash.

Parameters

string $attribute

Return Value

string

in Validator at line 2076
static protected string decodeAttributeWithPlaceholder(string $attribute)

Decode an attribute with a placeholder hash.

Parameters

string $attribute

Return Value

string

in Validator at line 2087
static void fakeDnsLookups(bool $value = true)

Fake the DNS lookups performed by validation rules so they always succeed.

Tests only. The setting persists for the worker lifetime; failing to reset it through Validator::flushState() can make later tests bypass real DNS validation.

Parameters

bool $value

Return Value

void

in Validator at line 2095
static void flushState()

Flush all static state.

Return Value

void

in Validator at line 2107
mixed __call(string $method, array $parameters)

Handle dynamic calls to class methods.

Parameters

string $method
array $parameters

Return Value

mixed

Exceptions

BadMethodCallException