FUEL CMS User Guide : Version 1.5.2


Validator Helper

Provides validation function for the Validator Library Class

Function Reference [+]

required('$var')

Check for variable solvency.

Returns

boolean

Parameters

(mixed) $var variable of any kind

regex('$var'=NULL, '$regex')

Check for matches within a string.

Returns

boolean

Parameters

(string) $var string containing content to be matched against
(string) $regex regular expression (delimiters excluded)

has_one_of_these(['$args'=NULL])

Ensure at least one array variable contains content.

Returns

boolean

Parameters

(array) $args array containing values of indiscriminate size

valid_email('$email')

Validate email address against standard email address form.

Returns

boolean

Parameters

(string) $email string containing email address

min_num('$var', ['$limit'=1])

Ensure a numeric value is greater than given size.

Returns

boolean

Parameters

(int) $var integer of any length
(int) $limit integer of any length to test against

max_num('$var', ['$limit'=1])

Ensure a numeric value is less than given size.

Returns

boolean

Parameters

(int) $var integer of any length
(int) $limit integer of any length to test against

is_between('$var', '$lo', '$hi')

Ensure a numeric value exists between a given size.

Returns

boolean

Parameters

(int) $var integer of any length
(int) $lo integer of any length to test low
(int) $hi integer of any length to test high

is_outside('$var', '$lo', '$hi')

Ensure a numeric value exists outside a given range.

Returns

boolean

Parameters

(int) $var integer of any length
(int) $lo integer of any length to test low
(int) $hi integer of any length to test high

length_max('$str', ['$limit'=1000])

Ensure a string's size exists within a certain limited range.

Returns

boolean

Parameters

(string) $str string of any length
(int) $limit integer to test string length against

length_min('$str', ['$limit'=1])

Ensure a string exists within a given limit.

Returns

boolean

Parameters

(string) $str string of any length
(int) $limit integer to test string length against

valid_phone('$str')

Ensure a valid phone number.

Returns

boolean

Parameters

(string) $str string of any length

is_equal_to('$val', '$val2')

Ensure to variables are equal.

Returns

boolean

Parameters

(mixed) $val mixed variable to test equality
(mixed) $val2 mixed variable to test equality

is_not_equal_to('$val', '$val2')

Ensure to variables are not equal.

Returns

boolean

Parameters

(mixed) $val mixed variable to test equality
(mixed) $val2 mixed variable to test equality

is_one_of_these('$val', [$search_in=array()])

Test array to see if value exists.

Returns

boolean

Parameters

(mixed) $val mixed variable
(array) $search_in array to test if value exists

is_not_one_of_these('$val', [$searchIn=array()])

Test array to see if value does not exist.

Returns

boolean

Parameters

(mixed) $val mixed variable
(array) $searchIn array to test if value exists

is_of_file_type('$fileName', '$fileType')

Test array to see if a file is of a given type.

Returns

boolean

Parameters

(string) $fileName filename
(string) $fileType mime value of file to test

valid_file_upload('$file_name')

Test array to see if a file is of a given type.

Returns

boolean

Parameters

(string) $file_name filename

is_safe_character('$val', [$allowed=array([0]=>_[1]=>-)])

Test string for valid characters.

Returns

boolean

Parameters

(mixed) $val string value
(array) $allowed list of allowed characters

valid_date_time('$date', ['$format'='ymd'], ['$delimiter'='-'])

Test date and time for proper format.

Returns

boolean

Parameters

(string) $date date as string value
(string) $format format of date to test against
(string) $delimiter delimiter of date value given for testing

valid_date('$date', ['$format'='ymd'], ['$delimiter'='-'])

Test date for proper format.

Returns

boolean

Parameters

(string) $date date as string value
(string) $format format of date to test against
(string) $delimiter delimiter of date value given for testing

valid_time('$date')

Test time for proper format.

Returns

boolean

Parameters

(string) $date date as string value

valid_mdy('$m', ['$d'=NULL], ['$y'=NULL])

Validate date passed.

Returns

boolean

Parameters

(string) $m month value or current date value
(string) $d day value
(string) $y year value

is_after_date('$date1', '$date2')

Check to dates to ensure one is after the other.

Returns

boolean

Parameters

(string) $date1 date value as string
(string) $date2 date value as string(should be later date)

is_before_date('$date1', '$date2')

Check to dates to ensure one is before the other.

Returns

boolean

Parameters

(string) $date1 date value as string(should be later date)
(string) $date2 date value as string

is_between_dates('$val', '$date1', '$date2')

Check to validate date exists between two others.

Returns

boolean

Parameters

(string) $val date value as string
(string) $date1 date value as string(low date)
(string) $date2 date value as string(high date)

is_future_date('$val')

Check to see if date is a future date.

Returns

boolean

Parameters

(string) $val date value as string

is_past_date('$val')

Check to see if date is past date.

Returns

boolean

Parameters

(string) $val date value as string

display_errors_js(['$ERRORS'=NULL])

Display user-defined errors via javascript.

Returns

string

Parameters

(mixed) $ERRORS collection of errors created by user

display_errors(['$ERRORS'=NULL], ['$class'='error'])

Display user-defined errors via javascript and html.

Returns

string

Parameters

(string) $ERRORS css class to define error styling
(mixed) $class collection of errors created by user

has_errors()

Check if any user defined errors have been defined.

Returns

boolean

add_error('$msg', ['$key'=NULL])

Add a user-defined error message.

Returns

boolean

Parameters

(string) $msg error message
(string) $key key value for error message array

add_errors('$errors')

Add a user-defined error message.

Returns

boolean

Parameters

(string) $errors error message

get_error(['$key'=NULL])

Get a user-defined error message.

Returns

string

Parameters

(string) $key key value for error message array

get_errors()

Get all global error messages.

Returns

array