Validator
final class Validator
Common validators.
Properties
| static array<string,string> | $messages |
Methods
Checks whether the control's value equals the argument (string comparison, supports arrays).
Checks whether the control's value does not equal the argument.
Always returns the argument value, used for static (constant) conditions.
Checks whether the control passes all its validation rules (used in conditions).
Checks whether the control's value falls within the specified range (inclusive).
Checks whether the control's value is greater than or equal to the minimum.
Checks whether the control's value is less than or equal to the maximum.
Checks whether the string length or array count falls within the given range [min, max].
Checks whether the string length or array count is at least the specified minimum.
Checks whether the string length or array count does not exceed the specified maximum.
Checks whether the submit button was used to submit the form.
Checks whether the control's value is a valid URL. Auto-prepends 'https://' if the scheme is missing.
Checks whether the control's value matches the regular expression (anchored, case-sensitive by default).
Checks whether the control's value is a non-negative integer string or int.
Checks whether the control's value is an integer. Normalizes the value by casting it to int.
Checks whether the control's value is a number. Normalizes spaces and commas and casts it to float.
Checks whether all uploaded files are within the size limit (in bytes).
Checks whether all uploaded files match one of the allowed MIME types (wildcards like 'image/*' are supported).
Checks whether all uploaded files are images (JPEG, PNG, GIF, WebP, AVIF).
Details
at line 52
static HtmlStringable
formatMessage(Rule $rule, bool $withValue = true)
| internal |
No description
at line 118
static bool
validateEqual(Control $control, mixed $arg)
Checks whether the control's value equals the argument (string comparison, supports arrays).
at line 145
static bool
validateNotEqual(Control $control, mixed $arg)
Checks whether the control's value does not equal the argument.
at line 154
static bool
validateStatic(Control $control, bool $arg)
Always returns the argument value, used for static (constant) conditions.
at line 163
static bool
validateFilled(BaseControl $control)
Checks whether the control is filled.
at line 172
static bool
validateBlank(BaseControl $control)
Checks whether the control is not filled.
at line 181
static bool
validateValid(BaseControl $control)
Checks whether the control passes all its validation rules (used in conditions).
at line 191
static bool
validateRange(Control $control, array $range)
Checks whether the control's value falls within the specified range (inclusive).
at line 204
static bool
validateMin(Control $control, int|float|string|DateTimeInterface $minimum)
Checks whether the control's value is greater than or equal to the minimum.
at line 213
static bool
validateMax(Control $control, int|float|string|DateTimeInterface $maximum)
Checks whether the control's value is less than or equal to the maximum.
at line 223
static bool
validateLength(Control $control, array|int $range)
Checks whether the string length or array count falls within the given range [min, max].
at line 237
static bool
validateMinLength(Control $control, int $length)
Checks whether the string length or array count is at least the specified minimum.
at line 246
static bool
validateMaxLength(Control $control, int $length)
Checks whether the string length or array count does not exceed the specified maximum.
at line 255
static bool
validateSubmitted(SubmitButton $control)
Checks whether the submit button was used to submit the form.
at line 264
static bool
validateEmail(Control $control)
Checks whether the control's value is a valid email address.
at line 273
static bool
validateUrl(Control $control)
Checks whether the control's value is a valid URL. Auto-prepends 'https://' if the scheme is missing.
at line 293
static bool
validatePattern(Control $control, string $pattern, bool $caseInsensitive = false)
Checks whether the control's value matches the regular expression (anchored, case-sensitive by default).
at line 307
static bool
validatePatternCaseInsensitive(Control $control, string $pattern)
No description
at line 316
static bool
validateNumeric(Control $control)
Checks whether the control's value is a non-negative integer string or int.
at line 327
static bool
validateInteger(Control $control)
Checks whether the control's value is an integer. Normalizes the value by casting it to int.
at line 344
static bool
validateFloat(Control $control)
Checks whether the control's value is a number. Normalizes spaces and commas and casts it to float.
at line 363
static bool
validateFileSize(UploadControl $control, int $limit)
Checks whether all uploaded files are within the size limit (in bytes).
at line 379
static bool
validateMimeType(UploadControl $control, string|array $mimeType)
Checks whether all uploaded files match one of the allowed MIME types (wildcards like 'image/*' are supported).
at line 396
static bool
validateImage(UploadControl $control)
Checks whether all uploaded files are images (JPEG, PNG, GIF, WebP, AVIF).