Standard Types
From PhpInputValidator
This are all the current possible possible types that come with phpInputValidator. You can also create a Custom Types if one of the following do not meet match what you are looking for.
For example:
- even
- day_month_year
Common Types
These are common PHP types which should not need an explaination
array
boolean / bool
real / double / float
integer / int
object
string / str
even
odd
Return
These types will be typecast to their type. For example if the type you want is bool but the variable is a '1' then it will return true not '1'.
Extended Types
alpha
String must only contain characters a-z. Case insensitive.
Example
FooBar
Return
string
alpha_lower
String must only contain characters a-z. Must be all lowercase.
Example
foobar
Return
string
alpha_numeric
String must only contain characters a-z or 0-9 Case insensitive.
Example
FooBar01
Return
string
alphanumeric_plus
String must only contain characters a-z, 0-9, -, or _. Case insensitive.
Example
Foo_Bar-01
Return
string
alpha_upper
String must only contain characters a-z. Must be all uppercase.
Example
FOOBAR
Return
string
american_express
String must be a valid American Express credit card.
Note
This check only validates the length and digit types. It does not check to make sure the number is actually an active card.
Example
378282246310005
Return
string
credit_card
String must be a valid credit card number. Doesn't care about the type of card.
Note
This check only validates the length and digit types. It does not check to make sure the number is actually an active card.
Example
378282246310005 6011000990139424
Return
string
day_month_year
A valid day month year string
Example
30/05/2002 30/5/2002 30/5/02 30-5-02
Return
string
discover_card
String must be a valid Discover credit card.
Note
This check only validates the length and digit types. It does not check to make sure the number is actually an active card.
Example
6011000990139424
Return
string
domain
String must have a valid tld
Example
www.foo.com foo.net http://www.foo.com .com
Return
string
Email address.
Example
foo@bar.com
Return
string
fuzzy_bool
Expanded bool types (see examples)
Example
true false 1 0 off on yes no y n
Return
bool
hex
A valid hexidecimal number
Example
FF00AA
Return
string
hex_color
A valid hexidecimal number with or without a #
Example
#FF00AA FF00AA
Return
string
hostname
A valid host name
Example
www.phpinputvalidator.org
Return
string
ip / ipv4
An IP v4 address.
Example
192.168.10.1
Return
string
ipv6
An IP v6 address.
Example
2001:db8:85a3:0:0:8a2e:370:7334
Return
string
isbn10
10 digit ISBN number
Example
90-70002-34-5
Return
string
isbn13
13 digit ISBN number
Example
978-1-4028-9462-6
Return
string
local_path
Local or absolute path.
Example
/www/foo/bar/
Return
string
mastercard
String must be a valid Mastercard credit card.
Note
This check only validates the length and digit types. It does not check to make sure the number is actually an active card.
Example
5555555555554444
Return
string
month_day_year
A valid month day year string
Example
05/30/2002 5/30/2002 5/30/02 5-30-02
Return
string
numeric
String must only contain numbers 0-9.
Example
12345678
Return
string
url
Website address. Can be http, https, or ftp.
Example
http://www.foobar.com https://www.foobar.com/bar/ http://www.foobar.com/bar/download.zip
Return
string
url_dual
Website address or a local path
Example
http://www.foobar.com/bar/ http://www.foobar.com/bar/download.zip /bar/download.zip
Return
string
us_currency
A valid currency number. With or without the $ and the .
Example
$5.00 $5 $3,000.33 5.00 5 3,000.33
Return
string
us_phone
A valid United States phone number.
Example
1-234-567-8910 1-234-567-8910 1-234-567-8910 (123) 456-7891 123.456.7891 12345678910
Return
string
us_social
A valid United States social security number.
Example
123-45-6789
Return
string
us_zip
A valid United States ZIP code
Example
12345 12345-6789
Return
string
visa
String must be a valid Visa credit card.
Note
This check only validates the length and digit types. It does not check to make sure the number is actually an active card.
Example
4012888888881881
Return
string
year_month_day
A valid year month day string
Example
2002/05/30 2002/5/30
Return
string