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 is filled.
Checks whether the control is not filled.
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 51
static HtmlStringable
formatMessage(Rule $rule, bool $withValue = true)
| internal |
No description
at line 117
static bool
validateEqual(Control $control, mixed $arg)
Checks whether the control's value equals the argument (string comparison, supports arrays).
at line 144
static bool
validateNotEqual(Control $control, mixed $arg)
Checks whether the control's value does not equal the argument.
at line 153
static bool
validateStatic(Control $control, bool $arg)
Always returns the argument value, used for static (constant) conditions.
at line 162
static bool
validateFilled(BaseControl $control)
Checks whether the control is filled.
at line 171
static bool
validateBlank(BaseControl $control)
Checks whether the control is not filled.
at line 180
static bool
validateValid(BaseControl $control)
Checks whether the control passes all its validation rules (used in conditions).
at line 190
static bool
validateRange(Control $control, array $range)
Checks whether the control's value falls within the specified range (inclusive).
at line 203
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 212
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 222
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 236
static bool
validateMinLength(Control $control, int $length)
Checks whether the string length or array count is at least the specified minimum.
at line 245
static bool
validateMaxLength(Control $control, int $length)
Checks whether the string length or array count does not exceed the specified maximum.
at line 254
static bool
validateSubmitted(SubmitButton $control)
Checks whether the submit button was used to submit the form.
at line 263
static bool
validateEmail(Control $control)
Checks whether the control's value is a valid email address.
at line 272
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 292
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 306
static bool
validatePatternCaseInsensitive(Control $control, string $pattern)
No description
at line 315
static bool
validateNumeric(Control $control)
Checks whether the control's value is a non-negative integer string or int.
at line 326
static bool
validateInteger(Control $control)
Checks whether the control's value is an integer. Normalizes the value by casting it to int.
at line 343
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 362
static bool
validateFileSize(UploadControl $control, int $limit)
Checks whether all uploaded files are within the size limit (in bytes).
at line 378
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 395
static bool
validateImage(UploadControl $control)
Checks whether all uploaded files are images (JPEG, PNG, GIF, WebP, AVIF).