Field_validation::validate()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 20

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 20
rs 9.6
c 0
b 0
f 0
cc 2
nc 2
nop 3
1
<?php
2
3
class Field_validation
4
{
5
	private $CI;
6
7
	public function __construct()
8
	{
9
		$this->CI =& get_instance();
10
		$this->CI->load->library('form_validation');
11
	}
12
13
	public function validate($value, $rules, $errors = [])
14
	{
15
		$this->CI->form_validation->reset_validation();
0 ignored issues
show
Bug introduced by
The property form_validation does not seem to exist in CI_Controller.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
16
17
		$data = [
18
			'field' => $value
19
		];
20
		$this->CI->form_validation->set_data($data);
21
22
		$this->CI->form_validation->set_rules('field', '', $rules, $errors);
23
24
		if ($this->CI->form_validation->run() === FALSE)
25
		{
26
			show_error('不正な入力です。');
27
		}
28
		else
29
		{
30
			return TRUE;
31
		}
32
	}
33
}
34