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

Class: Validate

Source Location: /Validate-0.6.2/Validate.php

Class Overview


Validation class


Author(s):

Version:

  • Release: @package_version@

Copyright:

  • 1997-2005 Pierre-Alain Joye,Tomas V.V.Cox

Methods


Inherited Variables

Inherited Methods


Class Details

[line 74]
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 277]

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) '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 130]

boolean email( string $email, [boolean $check_domain = false])

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

Parameters:

string   $email   —  URL to validate
boolean   $check_domain   —  Check or not if the domain exists

[ Top ]

multiple   [line 537]

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

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' minimun value 'max' maximum value

[ Top ]

string   [line 168]

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

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);

  • 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')

[ Top ]

_checkControlNumber   [line 501]

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

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

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:10:32 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.