final class Validator

Common validators.

Properties

static array<string,string> $messages

Methods

static HtmlStringable
formatMessage(Rule $rule, bool $withValue = true)

No description

static bool
validateEqual(Control $control, mixed $arg)

Checks whether the control's value equals the argument (string comparison, supports arrays).

static bool
validateNotEqual(Control $control, mixed $arg)

Checks whether the control's value does not equal the argument.

static bool
validateStatic(Control $control, bool $arg)

Always returns the argument value, used for static (constant) conditions.

static bool
validateFilled(BaseControl $control)

Checks whether the control is filled.

static bool
validateBlank(BaseControl $control)

Checks whether the control is not filled.

static bool
validateValid(BaseControl $control)

Checks whether the control passes all its validation rules (used in conditions).

static bool
validateRange(Control $control, array $range)

Checks whether the control's value falls within the specified range (inclusive).

static bool
validateMin(Control $control, int|float|string|DateTimeInterface $minimum)

Checks whether the control's value is greater than or equal to the minimum.

static bool
validateMax(Control $control, int|float|string|DateTimeInterface $maximum)

Checks whether the control's value is less than or equal to the maximum.

static bool
validateLength(Control $control, array|int $range)

Checks whether the string length or array count falls within the given range [min, max].

static bool
validateMinLength(Control $control, int $length)

Checks whether the string length or array count is at least the specified minimum.

static bool
validateMaxLength(Control $control, int $length)

Checks whether the string length or array count does not exceed the specified maximum.

static bool
validateSubmitted(SubmitButton $control)

Checks whether the submit button was used to submit the form.

static bool
validateEmail(Control $control)

Checks whether the control's value is a valid email address.

static bool
validateUrl(Control $control)

Checks whether the control's value is a valid URL. Auto-prepends 'https://' if the scheme is missing.

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).

static bool
validatePatternCaseInsensitive(Control $control, string $pattern)

No description

static bool
validateNumeric(Control $control)

Checks whether the control's value is a non-negative integer string or int.

static bool
validateInteger(Control $control)

Checks whether the control's value is an integer. Normalizes the value by casting it to int.

static bool
validateFloat(Control $control)

Checks whether the control's value is a number. Normalizes spaces and commas and casts it to float.

static bool
validateFileSize(UploadControl $control, int $limit)

Checks whether all uploaded files are within the size limit (in bytes).

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).

static bool
validateImage(UploadControl $control)

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

Parameters

Rule $rule
bool $withValue

Return Value

HtmlStringable

at line 117
static bool validateEqual(Control $control, mixed $arg)

Checks whether the control's value equals the argument (string comparison, supports arrays).

Parameters

Control $control
mixed $arg

Return Value

bool

at line 144
static bool validateNotEqual(Control $control, mixed $arg)

Checks whether the control's value does not equal the argument.

Parameters

Control $control
mixed $arg

Return Value

bool

at line 153
static bool validateStatic(Control $control, bool $arg)

Always returns the argument value, used for static (constant) conditions.

Parameters

Control $control
bool $arg

Return Value

bool

at line 162
static bool validateFilled(BaseControl $control)

Checks whether the control is filled.

Parameters

BaseControl $control

Return Value

bool

at line 171
static bool validateBlank(BaseControl $control)

Checks whether the control is not filled.

Parameters

BaseControl $control

Return Value

bool

at line 180
static bool validateValid(BaseControl $control)

Checks whether the control passes all its validation rules (used in conditions).

Parameters

BaseControl $control

Return Value

bool

at line 190
static bool validateRange(Control $control, array $range)

Checks whether the control's value falls within the specified range (inclusive).

Parameters

Control $control
array $range

Return Value

bool

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.

Parameters

Control $control
int|float|string|DateTimeInterface $minimum

Return Value

bool

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.

Parameters

Control $control
int|float|string|DateTimeInterface $maximum

Return Value

bool

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].

Parameters

Control $control
array|int $range

Return Value

bool

at line 236
static bool validateMinLength(Control $control, int $length)

Checks whether the string length or array count is at least the specified minimum.

Parameters

Control $control
int $length

Return Value

bool

at line 245
static bool validateMaxLength(Control $control, int $length)

Checks whether the string length or array count does not exceed the specified maximum.

Parameters

Control $control
int $length

Return Value

bool

at line 254
static bool validateSubmitted(SubmitButton $control)

Checks whether the submit button was used to submit the form.

Parameters

SubmitButton $control

Return Value

bool

at line 263
static bool validateEmail(Control $control)

Checks whether the control's value is a valid email address.

Parameters

Control $control

Return Value

bool

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.

Parameters

Control $control

Return Value

bool

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).

Parameters

Control $control
string $pattern
bool $caseInsensitive

Return Value

bool

at line 306
static bool validatePatternCaseInsensitive(Control $control, string $pattern)

No description

Parameters

Control $control
string $pattern

Return Value

bool

at line 315
static bool validateNumeric(Control $control)

Checks whether the control's value is a non-negative integer string or int.

Parameters

Control $control

Return Value

bool

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.

Parameters

Control $control

Return Value

bool

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.

Parameters

Control $control

Return Value

bool

at line 362
static bool validateFileSize(UploadControl $control, int $limit)

Checks whether all uploaded files are within the size limit (in bytes).

Parameters

UploadControl $control
int $limit

Return Value

bool

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).

Parameters

UploadControl $control
string|array $mimeType

Return Value

bool

at line 395
static bool validateImage(UploadControl $control)

Checks whether all uploaded files are images (JPEG, PNG, GIF, WebP, AVIF).

Parameters

UploadControl $control

Return Value

bool

Traits

StaticClass