Class CI_Form_validation - echiong/testRepo GitHub Wiki

##Class CI_Form_validation

Form Validation Class

Package: [[CodeIgniter<a href="Package CodeIgniter.Libraries.md">Libraries]]
Category: Validation
Author: ExpressionEngine Dev Team
Link: http://codeigniter.com/user_guide/libraries/form_validation.html
Located at system/libraries/Form_validation.php

##Methods summary


public __construct ( mixed $rules = array() )

Constructor


public set_rules ( mixed $field, string $label = '', mixed $rules = '' )

Set Rules

This function takes an array of field names and validation rules as input, validates the info, and stores it

Parameters

$field mixed

$label string

$rules


public string set_message ( string $lang, string $val = '' )

Set Error Message

Lets users set their own error messages on the fly. Note: The key name has to match the function name that it corresponds to.

Parameters

$lang string

$val string

Returns string


public set_error_delimiters ( string $prefix = '<p>', string $suffix = '</p>' )

Set The Error Delimiter

Permits a prefix/suffix to be added to each error message

Parameters

$prefix string

$suffix string


public error ( string $field = '', mixed $prefix = '', mixed $suffix = '' )

Get Error Message

Gets the error message associated with a particular field

Parameters

$field string
the field name

$prefix

$suffix


public str error_string ( string $prefix = '', string $suffix = '' )

Error String

Returns the error messages as a string, wrapped in the error delimiters

Parameters

$prefix string

$suffix string

Returns str


public boolean run ( mixed $group = '' )

Run the Validator

This function does all the work.

Returns boolean


protected mixed _reduce_array ( array $array, array $keys, integer $i = 0 )

Traverse a multidimensional $_POST array index until the data is found

Parameters

$array array

$keys array

$i integer

Returns mixed


protected null _reset_post_array ( )

Re-populate the _POST array with our finalized and processed data

Returns null


protected mixed _execute ( array $row, array $rules, mixed $postdata = NULL, integer $cycles = 0 )

Executes the Validation routines

Parameters

$row array

$rules array

$postdata mixed

$cycles integer

Returns mixed


protected string _translate_fieldname ( string $fieldname )

Translate a field name

Parameters

$fieldname string
the field name

Returns string


public set_value ( string $field = '', string $default = '' )

Get the value from a form

Permits you to repopulate a form field with the value it was submitted with, or, if that value doesn't exist, with the default

Parameters

$field string
the field name

$default string


public string set_select ( string $field = '', string $value = '', mixed $default = FALSE )

Set Select

Enables pull-down lists to be set to the value the user selected in the event of an error

Parameters

$field string

$value string

$default

Returns string


public string set_radio ( string $field = '', string $value = '', mixed $default = FALSE )

Set Radio

Enables radio buttons to be set to the value the user selected in the event of an error

Parameters

$field string

$value string

$default

Returns string


public string set_checkbox ( string $field = '', string $value = '', mixed $default = FALSE )

Set Checkbox

Enables checkboxes to be set to the value the user selected in the event of an error

Parameters

$field string

$value string

$default

Returns string


public boolean required ( string $str )

Required

Parameters

$str string

Returns boolean


public boolean regex_match ( string $str, regex $regex )

Performs a Regular Expression match test.

Parameters

$str string

$regex regex

Returns boolean


public boolean matches ( string $str, field $field )

Match one field to another

Parameters

$str string

$field field

Returns boolean


public boolean is_unique ( string $str, field $field )

Match one field to another

Parameters

$str string

$field field

Returns boolean


public boolean min_length ( string $str, value $val )

Minimum Length

Parameters

$str string

$val value

Returns boolean


public boolean max_length ( string $str, value $val )

Max Length

Parameters

$str string

$val value

Returns boolean


public boolean exact_length ( string $str, value $val )

Exact Length

Parameters

$str string

$val value

Returns boolean


public boolean valid_email ( string $str )

Valid Email

Parameters

$str string

Returns boolean


public boolean valid_emails ( string $str )

Valid Emails

Parameters

$str string

Returns boolean


public string valid_ip ( string $ip )

Validate IP Address

Parameters

$ip string

Returns string


public boolean alpha ( string $str )

Alpha

Parameters

$str string

Returns boolean


public boolean alpha_numeric ( string $str )

Alpha-numeric

Parameters

$str string

Returns boolean


public boolean alpha_dash ( string $str )

Alpha-numeric with underscores and dashes

Parameters

$str string

Returns boolean


public boolean numeric ( string $str )

Numeric

Parameters

$str string

Returns boolean


public boolean is_numeric ( string $str )

Is Numeric

Parameters

$str string

Returns boolean


public boolean integer ( string $str )

Integer

Parameters

$str string

Returns boolean


public boolean decimal ( string $str )

Decimal number

Parameters

$str string

Returns boolean


public boolean greater_than ( string $str, mixed $min )

Greather than

Parameters

$str string

$min

Returns boolean


public boolean less_than ( string $str, mixed $max )

Less than

Parameters

$str string

$max

Returns boolean


public boolean is_natural ( string $str )

Is a Natural number (0,1,2,3, etc.)

Parameters

$str string

Returns boolean


public boolean is_natural_no_zero ( string $str )

Is a Natural number, but not a zero (1,2,3, etc.)

Parameters

$str string

Returns boolean


public boolean valid_base64 ( string $str )

Valid Base64

Tests a string for characters outside of the Base64 alphabet as defined by RFC 2045 http://www.faqs.org/rfcs/rfc2045

Parameters

$str string

Returns boolean


public string prep_for_form ( string $data = '' )

Prep data for form

This function allows HTML to be safely shown in a form. Special characters are converted.

Parameters

$data string

Returns string


public string prep_url ( string $str = '' )

Prep URL

Parameters

$str string

Returns string


public string strip_image_tags ( string $str )

Strip Image Tags

Parameters

$str string

Returns string


public string xss_clean ( string $str )

XSS Clean

Parameters

$str string

Returns string


public string encode_php_tags ( string $str )

Convert PHP tags to entities

Parameters

$str string

Returns string

<table class="summary" id="properties">
<caption>Properties summary</caption>
<tr data-order="CI" id="$CI">
	<td class="attributes"><code>
		protected  
		mixed
	</code></td>

	<td class="name">

$CI

#
		<div class="description detailed">
			

		</div>
	</div></td>
</tr>
<tr data-order="_field_data" id="$_field_data">
	<td class="attributes"><code>
		protected  
		array
	</code></td>

	<td class="name">

$_field_data

array()
#
		<div class="description detailed">
			

		</div>
	</div></td>
</tr>
<tr data-order="_config_rules" id="$_config_rules">
	<td class="attributes"><code>
		protected  
		array
	</code></td>

	<td class="name">

$_config_rules

array()
#
		<div class="description detailed">
			

		</div>
	</div></td>
</tr>
<tr data-order="_error_array" id="$_error_array">
	<td class="attributes"><code>
		protected  
		array
	</code></td>

	<td class="name">

$_error_array

array()
#
		<div class="description detailed">
			

		</div>
	</div></td>
</tr>
<tr data-order="_error_messages" id="$_error_messages">
	<td class="attributes"><code>
		protected  
		array
	</code></td>

	<td class="name">

$_error_messages

array()
#
		<div class="description detailed">
			

		</div>
	</div></td>
</tr>
<tr data-order="_error_prefix" id="$_error_prefix">
	<td class="attributes"><code>
		protected  
		string
	</code></td>

	<td class="name">

$_error_prefix

'<p>'
#
		<div class="description detailed">
			

		</div>
	</div></td>
</tr>
<tr data-order="_error_suffix" id="$_error_suffix">
	<td class="attributes"><code>
		protected  
		string
	</code></td>

	<td class="name">

$_error_suffix

'</p>'
#
		<div class="description detailed">
			

		</div>
	</div></td>
</tr>
<tr data-order="error_string" id="$error_string">
	<td class="attributes"><code>
		protected  
		string
	</code></td>

	<td class="name">

$error_string

''
#
		<div class="description detailed">
			

		</div>
	</div></td>
</tr>
<tr data-order="_safe_form_data" id="$_safe_form_data">
	<td class="attributes"><code>
		protected  
		boolean
	</code></td>

	<td class="name">

$_safe_form_data

FALSE
#
		<div class="description detailed">
			

		</div>
	</div></td>
</tr>
</table>
⚠️ **GitHub.com Fallback** ⚠️