helpers/valid – Kohana API 2.3 Documentation

system/helpers/valid.php

Class: valid_Core

class valid_Core

Validation helper class.


Methods

valid_Core :: email

public static function email

Validate email, commonly used characters only

Parameters:

string email
email address

Return: boolean


valid_Core :: email_domain

public static function email_domain

Validate the domain of an email address by checking if the domain has a valid MX record.

Parameters:

string email
email address

Return: boolean


valid_Core :: email_rfc

public static function email_rfc

Validate email, RFC compliant version Note: This function is LESS strict than valid_email. Choose carefully.

Parameters:

string email
email address

See:

  • Originally by Cal Henderson, modified to fit Kohana syntax standards:
  • http://www.iamcal.com/publish/articles/php/parsing_email/
  • http://www.w3.org/Protocols/rfc822/

Return: boolean


valid_Core :: url

public static function url

Validate URL

Parameters:

string url
URL

Return: boolean


valid_Core :: ip

public static function ip

Validate IP

Parameters:

string ip
IP address
boolean ipv6
(FALSE) allow IPv6 addresses

Return: boolean


valid_Core :: credit_card

public static function credit_card

Validates a credit card number using the Luhn (mod10) formula.

Parameters:

integer number
credit card number
string or array type
(NULL) card type, or an array of card types

See: http://en.wikipedia.org/wiki/Luhn_algorithm

Return: boolean


valid_Core :: phone

public static function phone

Checks if a phone number is valid.

Parameters:

string number
phone number to check
lengths
(NULL)

Return: boolean


valid_Core :: alpha

public static function alpha

Checks whether a string consists of alphabetical characters only.

Parameters:

string str
input string
boolean utf8
(FALSE) trigger UTF-8 compatibility

Return: boolean


valid_Core :: alpha_numeric

public static function alpha_numeric

Checks whether a string consists of alphabetical characters and numbers only.

Parameters:

string str
input string
boolean utf8
(FALSE) trigger UTF-8 compatibility

Return: boolean


valid_Core :: alpha_dash

public static function alpha_dash

Checks whether a string consists of alphabetical characters, numbers, underscores and dashes only.

Parameters:

string str
input string
boolean utf8
(FALSE) trigger UTF-8 compatibility

Return: boolean


valid_Core :: digit

public static function digit

Checks whether a string consists of digits only (no dots or dashes).

Parameters:

string str
input string
boolean utf8
(FALSE) trigger UTF-8 compatibility

Return: boolean


valid_Core :: numeric

public static function numeric

Checks whether a string is a valid number (negative and decimal numbers allowed).

Parameters:

string str
input string

Return: boolean


valid_Core :: standard_text

public static function standard_text

Checks whether a string is a valid text. Letters, numbers, whitespace, dashes, periods, and underscores are allowed.

Parameters:

string str
$str

Return: boolean


valid_Core :: decimal

public static function decimal

Checks if a string is a proper decimal format. The format array can be used to specify a decimal length, or a number and decimal length, eg: array(2) would force the number to have 2 decimal places, array(4,2) would force the number to have 4 digits and 2 decimal places.

Parameters:

string str
input string
array format
(NULL) decimal format: y or x,y

Return: boolean