Class RSValidation

Description

A Utility Class for Validating all kinds of data.

General order of arguments for all methods:
The string to operate on is always the first argument.

Located in /code/framework/RSValidation/RSValidation.php (line 42)

Validate
   |
   --RSValidation
Method Summary
boolean creditCard (String $number)
boolean endsWith (String $string, mixed $endsWith, String $startsWith)
boolean isAlpha (String $string)
boolean isAlphanumeric (String $string)
boolean isAlphanumericIncludingUnderscore (String $string)
boolean isCleanText (String $string)
boolean isDate (string $date, [string $format = '%Y-%m-%d'], [array $min = array()], [array $max = array()])
void isDateTime (mixed $date, [mixed $format = '%Y-%m-%d %H:%i:%s'], [mixed $min = array()], [mixed $max = array()])
boolean isEmail (String $string, [mixed $checkDomain = false])
boolean isFloat (mixed $number, [int $minSize = null], [mixed $maxSize = null], [mixed $decimal = ','], [mixed $decPrec = false])
boolean isInt (mixed $number, [int $minSize = null], [mixed $maxSize = null])
boolean isNumeric (mixed $number)
void isString (mixed $str, [mixed $minLength = null], [mixed $maxLength = null])
boolean isStringExt (String $str, [int $minLength = null], [int $maxLength = null], [mixed $format = null])
void isTime (mixed $date, [mixed $format = '%H:%i:%s'], [mixed $min = array()], [mixed $max = array()])
void isTimestamp (mixed $date, [mixed $format = '%Y%m%d%H%i%s'], [mixed $min = array()], [mixed $max = array()])
boolean isValidDatabaseObjectName (String $string)
boolean startsWith (String $string, String $startsWith)
Methods
creditCard (line 277)

Returns true if the passed argument is valid credit card number.

This method is just a simple front-end for Validate::creditCard. Thanks to Ondrej Jombik.

  • return: True if number is valid, otherwise false.
boolean creditCard (String $number)
  • String $number: number
endsWith (line 89)

Returns true if the string passed as first argument ends with the string passed as second argument. Otherwise false is returned.

  • return: True if the first argument ends with the second argument; otherwise false
boolean endsWith (String $string, mixed $endsWith, String $startsWith)
  • String $string
  • String $startsWith
isAlpha (line 99)

Returns true if the passed string contains only alpha characters.

  • return: True if the string only contains alph characters.
boolean isAlpha (String $string)
  • String $string: The string to validate
isAlphanumeric (line 214)

Returns true if the passed string contains only alpha-numeric characters.

boolean isAlphanumeric (String $string)
  • String $string: The string to validate.
isAlphanumericIncludingUnderscore (line 227)

Returns true if the passed string contains only alpha-numeric characters and underscores (_)

This method is especially useful to find out if a value is avalid identifier for let's say a database object. If you want do find out just that use {@see isValidDatabaseObjectName}.

  • return: True if the string only contains alpha-numeric characters and underscores.
boolean isAlphanumericIncludingUnderscore (String $string)
  • String $string: The string to validate.
isCleanText (line 265)

Returns true if the passed string contains only alphanumeric characters of the Western alphabets

Checks if a string contains only a subset of alphanumerics characters allowed in the Western alphabets. Useful for validation of names.

  • return: True if $string contains only alphanumerics characters of the Western alphabets; otherwise false is returned.
boolean isCleanText (String $string)
  • String $string: The string to validate.
isDate (line 127)

Validate date and times. The default format is YYYY-MM-DD.

This method is just a simple front-end for Validate::date. Thanks to Tomas V.V.Cox and Pierre-Alain Joye.

boolean isDate (string $date, [string $format = '%Y-%m-%d'], [array $min = array()], [array $max = array()])
  • string $date: Date to validate
  • string $format: The format of the date (%d-%m-%Y)
  • array $min: The date has to be greater than this array($day, $month, $year)
  • array $max: The date has to be smaller than this array($day, $month, $year)
isDateTime (line 147)

This method is just like RSValidation::isDate but with a default format of YYYY-MM-DD HH:MM:SS.

void isDateTime (mixed $date, [mixed $format = '%Y-%m-%d %H:%i:%s'], [mixed $min = array()], [mixed $max = array()])
isEmail (line 252)

Returns true if the passed string is formatted as a valid e-mail adress.

This method is just a simple front-end for Validate::email. Thanks to Tomas V.V.Cox and Pierre-Alain Joye.

  • return: true if the string is a valid e-mail address.
boolean isEmail (String $string, [mixed $checkDomain = false])
  • String $string: The string to check.
isFloat (line 196)

Returns true if the first argument is a float.

This method is just a simple front-end for Validate::number. Thanks to Tomas V.V.Cox and Pierre-Alain Joye.

boolean isFloat (mixed $number, [int $minSize = null], [mixed $maxSize = null], [mixed $decimal = ','], [mixed $decPrec = false])
  • mixed $number: A string or a number
  • int $minSize: The maximal size; ignored if false;
  • mixed $decimal: The decimal char or false when decimal not allowed; optional; The default is false.
  • mixed $decPrec: The precision of the decimal value; optional; The default is false.
isInt (line 170)

Returns true if the first argument is a number of a numeric string and has the maximum and/or minumum size as specified by the second and third argument.

This method is just a simple front-end for Validate::number. Thanks to Tomas V.V.Cox and Pierre-Alain Joye.

  • return: True if the first argument matched all conditions.
boolean isInt (mixed $number, [int $minSize = null], [mixed $maxSize = null])
  • mixed $number: A string or a number
  • int $minSize: The maximal size; ignored if false;
isNumeric (line 111)

Returns true if the passed argument is a number or a numeric string.

In fact just a nicer way to call the native function http://www.php.net/is_numeric.

boolean isNumeric (mixed $number)
  • mixed $number: The value to validate.
isString (line 48)

An alias for isStringExt.

void isString (mixed $str, [mixed $minLength = null], [mixed $maxLength = null])
isStringExt (line 60)

Returns true if the first argument is a string (http://www.php.net/is_string) and has a minimum and/or maximum length.

  • return: True if the string passed as first argument matched all conditions.
  • source:
boolean isStringExt (String $str, [int $minLength = null], [int $maxLength = null], [mixed $format = null])
  • String $str: The string to validate.
  • int $minLength: The minimal length of the string; ignored if is false.
  • int $maxLength: The maximal length of the string; ignored if is false.
isTime (line 140)

This method is just like RSValidation::isDate but with a default format of HH:MM:SS.

void isTime (mixed $date, [mixed $format = '%H:%i:%s'], [mixed $min = array()], [mixed $max = array()])
isTimestamp (line 154)

This method is just like RSValidation::isDate but with a default format of YYYYMMDDHHMMSS.

void isTimestamp (mixed $date, [mixed $format = '%Y%m%d%H%i%s'], [mixed $min = array()], [mixed $max = array()])
isValidDatabaseObjectName (line 240)

Returns true if the passed string is valid database object name.

Returns true if the passed string contains only alpha-numeric characters and underscores. {@see isAlphanumericIncludingUnderscore} is called to find that out.

  • return: True if the string is a valid database object name.
boolean isValidDatabaseObjectName (String $string)
  • String $string: The string to validate.
startsWith (line 78)

Returns true if the string passed as first argument starts with the string passed as second argument. Otherwise false is returned.

  • return: True if the first argument starts with the second argument; otherwise false
boolean startsWith (String $string, String $startsWith)
  • String $string
  • String $startsWith

Documentation generated on Mon, 8 Dec 2003 13:13:11 +0100 by phpDocumentor 1.2.3