abstract class Rule implements RuleInterface

Base class for all form validation rules

Constants

INTEGER_TYPE

STRING_TYPE

FLOAT_TYPE

BOOLEAN_TYPE

NUMBER_TYPE

ITEMS_ARRAY

Properties

protected string $error Rule error
protected array $errorParams Error params
protected Collection $params Rule params

Methods

void
getType()

Return rule type

bool
validate(mixed $value)

Validate rule value callback

__construct($params = [], $error = null)

Constructor

Collection
getParams()

Return rule params

boolean
isRequired()

Return true if field rule is required

void
required(boolean $value = true)

Set rule required

bool
validateType(mixed $value, int $type)

Validate field type

void
setError(string $error)

Set validation error

array
getErrorParams()

Get error params

void
setErrorParams(array $params = [])

Set error params

string
getError()

Return validation error

string|null
getFieldName()

Return rule fixed rule name

Details

at line 53
abstract void getType()

Return rule type

Return Value

void

at line 61
bool validate(mixed $value)

Validate rule value callback

Parameters

mixed $value

Return Value

bool

at line 72
__construct($params = [], $error = null)

Constructor

Parameters

$params
$error

at line 85
Collection getParams()

Return rule params

Return Value

Collection

at line 95
boolean isRequired()

Return true if field rule is required

Return Value

boolean

at line 106
void required(boolean $value = true)

Set rule required

Parameters

boolean $value

Return Value

void

at line 118
protected bool validateType(mixed $value, int $type)

Validate field type

Parameters

mixed $value
int $type

Return Value

bool

at line 156
void setError(string $error)

Set validation error

Parameters

string $error

Return Value

void

at line 166
array getErrorParams()

Get error params

Return Value

array

at line 177
void setErrorParams(array $params = [])

Set error params

Parameters

array $params

Return Value

void

at line 187
string getError()

Return validation error

Return Value

string

at line 197
string|null getFieldName()

Return rule fixed rule name

Return Value

string|null