Class containing static methods to aid Validation
package | dstruct_common |
---|
isAPI(\unknown $api, \number $host) : boolean | \unknown | \Ambigous
todo | Shane.... wft? |
---|
\unknown
\number
boolean
\unknown
\Ambigous
<>|stringisAlpha(string $value) : boolean
string
boolean
isAlphaNumeric(string $value, string $allowablechars) : boolean
todo | split method from allowablechars stuff! |
---|
string
String to validate
string
\DStructGeneralException |
---|
boolean
isBankAccountNumber(integer $number) : boolean
Bank account numbers are just 8 numeric characters.
todo | Just us a regex? Do we even need this? Better to keep it as ppl may get confused with leading zeros?? |
---|
integer
boolean
isCountryCode(string $code) : boolean
todo | What about upper case stuff...?? Make it a param? |
---|---|
tod | What about method to return the country name and vice verse |
string
boolean
isDate(string $date) : boolean
todo | Only checks a very specific format! |
---|
string
Format dd/mm/yyyy
boolean
isDomain(string $domain) : boolean
Can't use FILTERs because they require scheme etc (docs are incorrect and flags do nothing). Many solutions on the internet were examined for checking domains, but all of them failed at least one test! Also, the PHP filter is broken at the time of writting.
author | David Lidstone |
---|
string
boolean
isEmailAddress(string $input) : boolean
N.B. This is NOT a check that the email EXISTS.
string
boolean
isGoogleAnalyticsKey(string $key) : boolean
WARNING: This is based on rather uncertain data... it seems to fit all keys tried so far, but Google may issue keys which don't fit this validation. Please let us know of any which don't validate but are genuine. Also, not that successful validation does not mean that the key is VALID with Google, just that is fits the format of a key.
string
boolean
isNumeric(mixed $value, boolean $allowdecimal, boolean $allowsigned) : boolean
PHP's built-in is_numeric() function also allows some more exotic values
such as hex, leading + chars and scientific notation.
PHP's ctype_digit() also checks type and requires an int... this can
cause validation failures, particularly when using data from forms.
mixed
String or Int to test
boolean
Allow decimal places
boolean
Allow values with negative sign char
boolean
isPostcode(string $pc) : boolean
See wikipedia for more info. Case insensitive. Regex from wikipedia?
string
Postcode to check
boolean
isSortCode(string $sortcode) : boolean
todo | changed, needs checking |
---|
string
SortCode to check
boolean
isStrongPassword(string $password, integer $minlength, boolean $numeric, boolean $casechange)
Fails if string is less than parsed length. Default is 8 characters. Fails if less than half the characters in the string are different. Default set to check for numeric characters fails if false If you expect non-ASCII compatible charactersets then dont use casechange. If you are using Western characterset then it is OK to use casechange
returns | boolean |
---|
string
Password to check
integer
Minimum allowable length of password.
boolean
Fail if there aren't numeric characters in the password.
boolean
Check that there are upper and lower case characters.
isTelephoneNumber(string $telno) : boolean
Only very basic checking. Strips spaces and elipses, checks for numeric and that there is a leading 0. Also checks that the length is 10 to 12 characters.
string
Number to validate
boolean
isUserDate(string $userdate, string $datename, \ProjectError $errobj) : boolean
Populates ProjectError with error strings using $datename as field.
todo | only validates in the format dd/mm/yyyyy! |
---|
string
string
\ProjectError
boolean
isUserTime(string $usertime, string $tsname, \ProjectError $errobj) : boolean
Populates ProjectError with error strings using $tsname as field.
string
string
\ProjectError
boolean
isUserTimestamp(string $date, string $tsname, \ProjectError $errobj) : boolean
Populates ProjectError with error strings using $tsname as field.
string
string
\ProjectError
boolean
isWindows() : boolean
boolean
isWithinRange(float $value, float $min, float $max) : boolean
float
Value to check
float
Minimum allowable value
float
Maximum allowable value
boolean
isWithinStringLength(string $str, integer $min, integer $max) : boolean
string
String to check
integer
Minimum number of characters
integer
Maximum number of characters
boolean
isYouTubeAPI(\unknown $api) : boolean
todo | Downloads whole video to check????? DELETE!? |
---|
\unknown
boolean