for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Rougin\Wildfire\Traits;
/**
* Validate Trait
*
* @package Wildfire
* @author Rougin Royce Gutib <[email protected]>
*/
trait ValidateTrait
{
* @var array
protected $errors = array();
* Returns a listing of error messages.
* @return array
public function errors()
return $this->errors;
}
* Validates the specified data based on the validation rules.
* @param array $data
* @return boolean
public function validate(array $data = array())
$this->load->library('form_validation');
load
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
class MyClass { } $x = new MyClass(); $x->foo = true;
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:
class MyClass { public $foo; } $x = new MyClass(); $x->foo = true;
! empty($data) && $this->form_validation->set_data($data);
form_validation
$this->form_validation->set_rules($this->validation_rules);
validation_rules
if (! ($validated = $this->form_validation->run())) {
$this->errors = $this->form_validation->error_array();
return $validated;
* NOTE: To be removed in v1.0.0. Use $this->errors instead.
public function validation_errors()
return $this->errors();
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: