选择语言 :

Core_Valid

验证类

API - Core_Valid

  • Valid::not_empty - Checks if a field is not empty.
  • Valid::regex - Checks a field against a regular expression.
  • Valid::min_length - Checks that a field is long enough.
  • Valid::max_length - Checks that a field is short enough.
  • Valid::exact_length - Checks that a field is exactly the right length.
  • Valid::equals - Checks that a field is exactly the value required.
  • Valid::email - Check an email address for correct format.
  • Valid::email_domain - Validate the domain of an email address by checking if the domain has a
  • Valid::url - Validate a URL.
  • Valid::ip - Validate an IP.
  • Valid::credit_card - Validates a credit card number, with a Luhn check if possible.
  • Valid::luhn - Validate a number against the [Luhn](http://en.wikipedia.org/wiki/Luhn_algorithm)
  • Valid::date - Tests if a string is a valid date string.
  • Valid::alpha - Checks whether a string consists of alphabetical characters only.
  • Valid::alpha_numeric - Checks whether a string consists of alphabetical characters and numbers only.
  • Valid::alpha_dash - Checks whether a string consists of alphabetical characters, numbers, underscores and dashes only.
  • Valid::digit - Checks whether a string consists of digits only (no dots or dashes).
  • Valid::numeric - Checks whether a string is a valid number (negative and decimal numbers allowed).
  • Valid::range - Tests if a number is within a range.
  • Valid::decimal - Checks if a string is a proper decimal format. Optionally, a specific
  • Valid::color - Checks if a string is a proper hexadecimal HTML color value. The validation
  • Valid::matches - Checks if a field matches the value of another field.
author
呼吸二氧化碳 jonwang@myqee.com
category
MyQEE
package
System
subpackage
Core
copyright
Copyright © 2008-2013 myqee.com
license
http://www.myqee.com/license.html

Valid::not_empty( )

Checks if a field is not empty.

返回值
  • boolean

Valid::regex( $value , $expression )

Checks a field against a regular expression.

参数列表

参数 类型 描述 默认值
$value string Value
$expression string Regular expression to match (including delimiters)
返回值
  • boolean

Valid::min_length( $value , $length )

Checks that a field is long enough.

参数列表

参数 类型 描述 默认值
$value string Value
$length integer Minimum length required
返回值
  • boolean

Valid::max_length( $value , $length )

Checks that a field is short enough.

参数列表

参数 类型 描述 默认值
$value string Value
$length integer Maximum length required
返回值
  • boolean

Valid::exact_length( $value , $length )

Checks that a field is exactly the right length.

参数列表

参数 类型 描述 默认值
$value string Value
$length integer Exact length required
返回值
  • boolean

Valid::equals( $value , $required )

Checks that a field is exactly the value required.

参数列表

参数 类型 描述 默认值
$value string Value
$required string Required value
返回值
  • boolean

Valid::email( $email , $strict = false)

Check an email address for correct format.

参数列表

参数 类型 描述 默认值
$email string Email address
$strict boolean Strict RFC compatibility bool false
返回值
  • boolean

Valid::email_domain( $email )

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

参数列表

参数 类型 描述 默认值
$email string Email address
返回值
  • boolean

Valid::url( $url )

Validate a URL.

参数列表

参数 类型 描述 默认值
$url string URL
返回值
  • boolean

Valid::ip( $ip , $allow_private = true)

Validate an IP.

参数列表

参数 类型 描述 默认值
$ip string IP address
$allow_private boolean Allow private IP networks bool true
返回值
  • boolean

Valid::credit_card( $number , $type = null)

Validates a credit card number, with a Luhn check if possible.

参数列表

参数 类型 描述 默认值
$number integer Credit card number
$type string|array Card type, or an array of card types null
返回值
  • boolean

Valid::luhn( $number )

Validate a number against the Luhn (mod10) formula.

参数列表

参数 类型 描述 默认值
$number string Number to check
返回值
  • boolean

Valid::date( $str )

Tests if a string is a valid date string.

参数列表

参数 类型 描述 默认值
$str string Date to check
返回值
  • boolean

Valid::alpha( $str , $utf8 = false)

Checks whether a string consists of alphabetical characters only.

参数列表

参数 类型 描述 默认值
$str string Input string
$utf8 boolean Trigger UTF-8 compatibility bool false
返回值
  • boolean

Valid::alpha_numeric( $str , $utf8 = false)

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

参数列表

参数 类型 描述 默认值
$str string Input string
$utf8 boolean Trigger UTF-8 compatibility bool false
返回值
  • boolean

Valid::alpha_dash( $str , $utf8 = false)

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

参数列表

参数 类型 描述 默认值
$str string Input string
$utf8 boolean Trigger UTF-8 compatibility bool false
返回值
  • boolean

Valid::digit( $str , $utf8 = false)

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

参数列表

参数 类型 描述 默认值
$str string Input string
$utf8 boolean Trigger UTF-8 compatibility bool false
返回值
  • boolean

Valid::numeric( $str )

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

Uses {@link http://www.php.net/manual/en/function.localeconv.php locale conversion} to allow decimal point to be locale specific.

参数列表

参数 类型 描述 默认值
$str string Input string
返回值
  • boolean

Valid::range( $number , $min , $max )

Tests if a number is within a range.

参数列表

参数 类型 描述 默认值
$number string Number to check
$min integer Minimum value
$max integer Maximum value
返回值
  • boolean

Valid::decimal( $str , $places = 2, $digits = null)

Checks if a string is a proper decimal format. Optionally, a specific number of digits can be checked too.

参数列表

参数 类型 描述 默认值
$str string Number to check
$places integer Number of decimal places integer 2
$digits integer Number of digits null
返回值
  • boolean

Valid::color( $str )

Checks if a string is a proper hexadecimal HTML color value. The validation is quite flexible as it does not require an initial "#" and also allows for the short notation using only three instead of six hexadecimal characters.

参数列表

参数 类型 描述 默认值
$str string Input string
返回值
  • boolean

Valid::matches( $array , $field , $match )

Checks if a field matches the value of another field.

参数列表

参数 类型 描述 默认值
$array array Array of values
$field string Field name
$match string Field name to match
返回值
  • boolean