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
booleanisAlphaNumeric(string $value, string $allowablechars) : boolean
| todo | split method from allowablechars stuff! |
|---|
stringString to validate
string
\DStructGeneralException |
|---|
booleanisBankAccountNumber(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
booleanisCountryCode(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
booleanisDate(string $date) : boolean
| todo | Only checks a very specific format! |
|---|
stringFormat dd/mm/yyyy
booleanisDomain(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
booleanisEmailAddress(string $input) : boolean
N.B. This is NOT a check that the email EXISTS.
string
booleanisGoogleAnalyticsKey(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
booleanisNumeric(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.
mixedString or Int to test
booleanAllow decimal places
booleanAllow values with negative sign char
booleanisPostcode(string $pc) : boolean
See wikipedia for more info. Case insensitive. Regex from wikipedia?
stringPostcode to check
booleanisSortCode(string $sortcode) : boolean
| todo | changed, needs checking |
|---|
stringSortCode to check
booleanisStrongPassword(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 |
|---|
stringPassword to check
integerMinimum allowable length of password.
booleanFail if there aren't numeric characters in the password.
booleanCheck 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.
stringNumber to validate
booleanisUserDate(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
booleanisUserTime(string $usertime, string $tsname, \ProjectError $errobj) : boolean
Populates ProjectError with error strings using $tsname as field.
string
string
\ProjectError
booleanisUserTimestamp(string $date, string $tsname, \ProjectError $errobj) : boolean
Populates ProjectError with error strings using $tsname as field.
string
string
\ProjectError
booleanisWindows() : boolean
booleanisWithinRange(float $value, float $min, float $max) : boolean
floatValue to check
floatMinimum allowable value
floatMaximum allowable value
booleanisWithinStringLength(string $str, integer $min, integer $max) : boolean
stringString to check
integerMinimum number of characters
integerMaximum number of characters
booleanisYouTubeAPI(\unknown $api) : boolean
| todo | Downloads whole video to check????? DELETE!? |
|---|
\unknown
boolean