My Project
 All Data Structures Namespaces Functions Variables
Public Member Functions | Protected Member Functions | Protected Attributes
CI_Form_validation Class Reference

Public Member Functions

 __construct ($rules=array())
 
 set_rules ($field, $label= '', $rules= '')
 
 set_message ($lang, $val= '')
 
 set_error_delimiters ($prefix= '< p >', $suffix= '</p >')
 
 error ($field= '', $prefix= '', $suffix= '')
 
 error_string ($prefix= '', $suffix= '')
 
 run ($group= '')
 
 set_value ($field= '', $default= '')
 
 set_select ($field= '', $value= '', $default=FALSE)
 
 set_radio ($field= '', $value= '', $default=FALSE)
 
 set_checkbox ($field= '', $value= '', $default=FALSE)
 
 required ($str)
 
 regex_match ($str, $regex)
 
 matches ($str, $field)
 
 is_unique ($str, $field)
 
 min_length ($str, $val)
 
 max_length ($str, $val)
 
 exact_length ($str, $val)
 
 valid_email ($str)
 
 valid_emails ($str)
 
 valid_ip ($ip, $which= '')
 
 alpha ($str)
 
 alpha_numeric ($str)
 
 alpha_dash ($str)
 
 numeric ($str)
 
 is_numeric ($str)
 
 integer ($str)
 
 decimal ($str)
 
 greater_than ($str, $min)
 
 less_than ($str, $max)
 
 is_natural ($str)
 
 is_natural_no_zero ($str)
 
 valid_base64 ($str)
 
 prep_for_form ($data= '')
 
 prep_url ($str= '')
 
 strip_image_tags ($str)
 
 xss_clean ($str)
 
 encode_php_tags ($str)
 

Protected Member Functions

 _reduce_array ($array, $keys, $i=0)
 
 _reset_post_array ()
 
 _execute ($row, $rules, $postdata=NULL, $cycles=0)
 
 _translate_fieldname ($fieldname)
 

Protected Attributes

 $CI
 
 $_field_data = array()
 
 $_config_rules = array()
 
 $_error_array = array()
 
 $_error_messages = array()
 
 $_error_prefix = '<p>'
 
 $_error_suffix = '</p>'
 
 $error_string = ''
 
 $_safe_form_data = FALSE
 

Constructor & Destructor Documentation

__construct (   $rules = array())

Constructor

Member Function Documentation

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

Executes the Validation routines

private

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

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

private

Parameters
array
array
integer
Returns
mixed
_reset_post_array ( )
protected

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

private

Returns
null
_translate_fieldname (   $fieldname)
protected

Translate a field name

private

Parameters
stringthe field name
Returns
string
alpha (   $str)

Alpha

public

Parameters
string
Returns
bool
alpha_dash (   $str)

Alpha-numeric with underscores and dashes

public

Parameters
string
Returns
bool
alpha_numeric (   $str)

Alpha-numeric

public

Parameters
string
Returns
bool
decimal (   $str)

Decimal number

public

Parameters
string
Returns
bool
encode_php_tags (   $str)

Convert PHP tags to entities

public

Parameters
string
Returns
string
error (   $field = '',
  $prefix = '',
  $suffix = '' 
)

Get Error Message

Gets the error message associated with a particular field

public

Parameters
stringthe field name
Returns
void
error_string (   $prefix = '',
  $suffix = '' 
)

Error String

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

public

Parameters
string
string
Returns
str
exact_length (   $str,
  $val 
)

Exact Length

public

Parameters
string
value
Returns
bool
greater_than (   $str,
  $min 
)

Greather than

public

Parameters
string
Returns
bool
integer (   $str)

Integer

public

Parameters
string
Returns
bool
is_natural (   $str)

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

public

Parameters
string
Returns
bool
is_natural_no_zero (   $str)

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

public

Parameters
string
Returns
bool
is_numeric (   $str)

Is Numeric

public

Parameters
string
Returns
bool
is_unique (   $str,
  $field 
)

Match one field to another

public

Parameters
string
field
Returns
bool
less_than (   $str,
  $max 
)

Less than

public

Parameters
string
Returns
bool
matches (   $str,
  $field 
)

Match one field to another

public

Parameters
string
field
Returns
bool
max_length (   $str,
  $val 
)

Max Length

public

Parameters
string
value
Returns
bool
min_length (   $str,
  $val 
)

Minimum Length

public

Parameters
string
value
Returns
bool
numeric (   $str)

Numeric

public

Parameters
string
Returns
bool
prep_for_form (   $data = '')

Prep data for form

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

public

Parameters
string
Returns
string
prep_url (   $str = '')

Prep URL

public

Parameters
string
Returns
string
regex_match (   $str,
  $regex 
)

Performs a Regular Expression match test.

public

Parameters
string
regex
Returns
bool
required (   $str)

Required

public

Parameters
string
Returns
bool
run (   $group = '')

Run the Validator

This function does all the work.

public

Returns
bool
set_checkbox (   $field = '',
  $value = '',
  $default = FALSE 
)

Set Checkbox

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

public

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

Set The Error Delimiter

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

public

Parameters
string
string
Returns
void
set_message (   $lang,
  $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.

public

Parameters
string
string
Returns
string
set_radio (   $field = '',
  $value = '',
  $default = FALSE 
)

Set Radio

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

public

Parameters
string
string
Returns
string
set_rules (   $field,
  $label = '',
  $rules = '' 
)

Set Rules

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

public

Parameters
mixed
string
Returns
void
set_select (   $field = '',
  $value = '',
  $default = FALSE 
)

Set Select

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

public

Parameters
string
string
Returns
string
set_value (   $field = '',
  $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

public

Parameters
stringthe field name
string
Returns
void
strip_image_tags (   $str)

Strip Image Tags

public

Parameters
string
Returns
string
valid_base64 (   $str)

Valid Base64

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

public

Parameters
string
Returns
bool
valid_email (   $str)

Valid Email

public

Parameters
string
Returns
bool
valid_emails (   $str)

Valid Emails

public

Parameters
string
Returns
bool
valid_ip (   $ip,
  $which = '' 
)

Validate IP Address

public

Parameters
string
string"ipv4" or "ipv6" to validate a specific ip format
Returns
string
xss_clean (   $str)

XSS Clean

public

Parameters
string
Returns
string

The documentation for this class was generated from the following file: