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

Class: Validate

Source Location: /Validate-0.7.0/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

Methods


Inherited Variables

Inherited Methods


Class Details

[line 77]
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 ]


Method Detail

date   [line 451]

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 278]

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

[ Top ]

multiple   [line 749]

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 94]

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 327]

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 383]

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 713]

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   —  (optionsl) number
int   $subtract   —  (optional) numbier
   &$weights   — 

[ Top ]

_getControlNumber   [line 684]

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 654]

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 Mon, 11 Mar 2019 14:48:49 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.