Validate
[ class tree: Validate ] [ index: Validate ] [ all elements ]

Class: Validate

Source Location: /Validate-0.8.5/Validate.php

Class Overview


Validation class


Author(s):

Version:

  • Release: @package_version@

Copyright:

  • 1997-2006 Pierre-Alain Joye,Tomas V.V.Cox,Amir Mohammad Saied

Variables

Methods


Inherited Variables

Inherited Methods


Class Details

[line 82]
Validation class

Package to validate various datas. It includes :

  • numbers (min/max, decimal or not)
  • email (syntax, domain check)
  • string (predifined type alpha upper and/or lowercase, numeric,...)
  • date (min, max)
  • uri (RFC2396)
  • possibility valid multiple data with a single method call (::multiple)



[ Top ]


Class Variables

$_cctld = array(
        'ac',
        'ad','ae','af','ag',
        'ai','al','am','an',
        'ao','aq','ar','as',
        'at','au','aw','ax',
        'az','ba','bb','bd',
        'be','bf','bg','bh',
        'bi','bj','bm','bn',
        'bo','br','bs','bt',
        'bu','bv','bw','by',
        'bz','ca','cc','cd',
        'cf','cg','ch','ci',
        'ck','cl','cm','cn',
        'co','cr','cs','cu',
        'cv','cx','cy','cz',
        'de','dj','dk','dm',
        'do','dz','ec','ee',
        'eg','eh','er','es',
        'et','eu','fi','fj',
        'fk','fm','fo','fr',
        'ga','gb','gd','ge',
        'gf','gg','gh','gi',
        'gl','gm','gn','gp',
        'gq','gr','gs','gt',
        'gu','gw','gy','hk',
        'hm','hn','hr','ht',
        'hu','id','ie','il',
        'im','in','io','iq',
        'ir','is','it','je',
        'jm','jo','jp','ke',
        'kg','kh','ki','km',
        'kn','kp','kr','kw',
        'ky','kz','la','lb',
        'lc','li','lk','lr',
        'ls','lt','lu','lv',
        'ly','ma','mc','md',
        'me','mg','mh','mk',
        'ml','mm','mn','mo',
        'mp','mq','mr','ms',
        'mt','mu','mv','mw',
        'mx','my','mz','na',
        'nc','ne','nf','ng',
        'ni','nl','no','np',
        'nr','nu','nz','om',
        'pa','pe','pf','pg',
        'ph','pk','pl','pm',
        'pn','pr','ps','pt',
        'pw','py','qa','re',
        'ro','rs','ru','rw',
        'sa','sb','sc','sd',
        'se','sg','sh','si',
        'sj','sk','sl','sm',
        'sn','so','sr','st',
        'su','sv','sy','sz',
        'tc','td','tf','tg',
        'th','tj','tk','tl',
        'tm','tn','to','tp',
        'tr','tt','tv','tw',
        'tz','ua','ug','uk',
        'us','uy','uz','va',
        'vc','ve','vg','vi',
        'vn','vu','wf','ws',
        'ye','yt','yu','za',
        'zm','zw',
    )

[line 142]

Country code top-level domains

This is an array of the official country codes top-level domains

  • Var: (Country Code Top-Level Domain)
  • Access: protected

Type:   array


[ Top ]

$_gtld = array(
        'aero',
        'biz',
        'cat',
        'com',
        'coop',
        'edu',
        'gov',
        'info',
        'int',
        'jobs',
        'mil',
        'mobi',
        'museum',
        'name',
        'net',
        'org',
        'pro',
        'travel',
        'asia',
        'post',
        'tel',
        'geo',
    )

[line 108]

Generic top-level domain

This is an array of the official generic top-level domains.

  • Var: (Generic top-level domains)
  • Access: protected

Type:   array


[ Top ]

$_itld = array(
        'arpa',
        'root',
    )

[line 94]

International Top-Level Domain

This is an array of the known international top-level domain names.

  • Var: (International top-level domains)
  • Access: protected

Type:   array


[ Top ]



Method Detail

date   [line 749]

boolean date( string $date, array $options)

Validate date and times. Note that this method need the Date_Calc class
  • Return: true if valid date/time, false if not
  • Access: public

Parameters:

string   $date     Date to validate
array   $options     array options where : 'format' The format of the date (%d-%m-%Y) or rfc822_compliant 'min' The date has to be greater than this array($day, $month, $year) or PEAR::Date object 'max' The date has to be smaller than this array($day, $month, $year) or PEAR::Date object

[ Top ]

email   [line 519]

boolean email( string $email, [mixed $options = null])

Validate an email
  • Return: true if valid email, false if not
  • Access: public

Parameters:

string   $email     email to validate
mixed   $options     

boolean (BC) $check_domain Check or not if the domain exists array $options associative array of options 'check_domain' boolean Check or not if the domain exists 'use_rfc822' boolean Apply the full RFC822 grammar

Ex. $options = array( 'check_domain' => 'true', 'fullTLDValidation' => 'true', 'use_rfc822' => 'true', 'VALIDATE_GTLD_EMAILS' => 'true', 'VALIDATE_CCTLD_EMAILS' => 'true', 'VALIDATE_ITLD_EMAILS' => 'true', );


[ Top ]

executeFullEmailValidation   [line 484]

true executeFullEmailValidation( string $email, array $arrayOfTLDs)

Execute the validation

This function will execute the full email vs tld validation using an array of tlds passed to it.

  • Return: or false (Depending on if it validates or if it does not)
  • Access: public

Parameters:

string   $email     The email to validate.
array   $arrayOfTLDs     The array of the TLDs to validate

[ Top ]

multiple   [line 1063]

array multiple( &$data, &$val_type, [boolean $remove = false], array $data, array $val_type)

Bulk data validation for data introduced in the form of an assoc array in the form $var_name => $value.

Can be used on any of Validate subpackages

  • Return: value name => true|false the value name comes from the data key
  • Access: public

Parameters:

array   $data     Ex: array('name' => 'toto', 'email' => 'toto@thing.info');
array   $val_type     Contains the validation type and all parameters used in. 'val_type' is not optional others validations properties must have the same name as the function parameters. Ex: array('toto'=>array('type'=>'string','format'='toto@thing.info','min_length'=>5));
boolean   $remove     if set, the elements not listed in data will be removed
   &$data     
   &$val_type     

[ Top ]

number   [line 260]

boolean number( string $number, [array $options = array()])

Validate a number
  • Return: true if valid number, false if not
  • Access: public

Parameters:

string   $number     Number to validate
array   $options     array where: 'decimal' is the decimal char or false when decimal not allowed. i.e. ',.' to allow both ',' and '.' 'dec_prec' Number of allowed decimals 'min' minimum value 'max' maximum value

[ Top ]

string   [line 611]

boolean string( string $string, array $options)

Validate a string using the given format 'format'
  • Return: true if valid string, false if not
  • Access: public

Parameters:

string   $string     String to validate
array   $options     Options array where: 'format' is the format of the string Ex:VALIDATE_NUM . VALIDATE_ALPHA (see constants) 'min_length' minimum length 'max_length' maximum length

[ Top ]

uri   [line 673]

boolean uri( string $url, [array $options = null])

Validate an URI (RFC2396)

This function will validate 'foobarstring' by default, to get it to validate only http, https, ftp and such you have to pass it in the allowed_schemes option, like this:

  1.  $options = array('allowed_schemes' => array('http''https''ftp'))
  2.  var_dump(Validate::uri('http://www.example.org'$options));

NOTE 1: The rfc2396 normally allows middle '-' in the top domain e.g. http://example.co-m should be valid However, as '-' is not used in any known TLD, it is invalid NOTE 2: As double shlashes // are allowed in the path part, only full URIs including an authority can be valid, no relative URIs the // are mandatory (optionally preceeded by the 'sheme:' ) NOTE 3: the full complience to rfc2396 is not achieved by default the characters ';/?:@$,' will not be accepted in the query part if not urlencoded, refer to the option "strict'"

  • Return: true if valid uri, false if not
  • Access: public

Parameters:

string   $url     URI to validate
array   $options     Options used by the validation method. key => type 'domain_check' => boolean Whether to check the DNS entry or not 'allowed_schemes' => array, list of protocols List of allowed schemes ('http', 'ssh+svn', 'mms') 'strict' => string the refused chars in query and fragment parts default: ';/?:@$,' empty: accept all rfc2396 foreseen chars

[ Top ]

_checkControlNumber   [line 1026]

bool _checkControlNumber( string $number, &$weights, [int $modulo = 10], [int $subtract = 0], array $weights)

Validates a number
  • Return: true if valid, false if not
  • Access: protected

Parameters:

string   $number     number to validate
array   $weights     reference to array of weights
int   $modulo     (optional) number
int   $subtract     (optional) number
   &$weights     

[ Top ]

_fullTLDValidation   [line 445]

bool _fullTLDValidation( string $email, array $options)

Full TLD Validation function

This function is used to make a much more proficient validation against all types of official domain names.

  • Return: True if validating succeeds
  • Access: protected

Parameters:

string   $email     The email address to check.
array   $options     The options for validation

[ Top ]

_getControlNumber   [line 996]

int _getControlNumber( string $number, &$weights, [int $modulo = 10], [int $subtract = 0], [bool $allow_high = false], array $weights)

Calculates control digit for a given number
  • Return: -1 calculated control number is returned
  • Access: protected

Parameters:

string   $number     number string
array   $weights     reference to array of weights
int   $modulo     (optionsl) number
int   $subtract     (optional) number
bool   $allow_high     (optional) true if function can return number higher than 10
   &$weights     

[ Top ]

_multWeights   [line 965]

int _multWeights( string $number, &$weights, array $weights)

Calculates sum of product of number digits with weights
  • Return: returns product of number digits with weights
  • Access: protected

Parameters:

string   $number     number string
array   $weights     reference to array of weights
   &$weights     

[ Top ]


Documentation generated on Sun, 18 Dec 2011 12:30:08 +0000 by phpDocumentor 1.4.3. PEAR Logo Copyright © PHP Group 2004.