NAMESPACE: Bootstrap/Models

Models/Validators.php

public function validateByRules($rules,$variables)

Validates input variables by a set of rules. If variables are not explicitly passed it will default to the currently submitted ones.

Validation depends on the rules and each of them passing. The validation rules are passed as key value pairs where the key is the name of the variable in the input and the value is the ruleset.

The ruleset is a string that can define multiple validation rules. Each rule in the string is separated using ‘|’ as a delimeter. Additional parameters can be passed to the rule using ‘:’

Each rule depends on the trait having defined a method with the appropriate name.

Example ruleset: aray( ‘name’ => ’empty|length:3′, ‘age’ => ’empty|greater_than:18′, ’email’ => ’empty|email’ )

Supported rules: empty, length, greater_than, less_than, email, website, password

variable

$rules
$variables
protected function getValidationErrorMessage($rule,$variable,$param)

Fill a validation error based on the provided rule and variable name. Different rules have different validation error formatting.

The errors are filled in the $validation_errors property and are then used in the controller or view to signal the user.

If you defined a new validation rule you should add a validation message for it here. Otherwise it will display the default one.

variable

$rule
$variable
$param
public function validateEmpty($value)

Validates whether the given value is not empty.

variable

$value
public function validateLength($value,$length)

variable

$value
$length
public function validateGreaterThan($value,$number)

variable

$value
$number
public function validateLessThan($value,$number)

variable

$value
$number
public function validateEmail($email)

Email validation

variable

$email
public function validateWebsite($url)

Website validation

variable

$url
public function validatePassword($password,$strict)

Password validation

variable

$password
$strict