dolibarr 21.0.0-alpha
Validate Class Reference

Class toolbox to validate values. More...

Public Member Functions

 __construct ($db, $outputLang=null)
 Constructor.
 
 isEmail ($email, $maxLength=0)
 Check for e-mail validity.
 
 isPrice ($price)
 Check for price validity.
 
 isTimestamp ($stamp)
 Check for timestamp validity.
 
 isPhone ($phone)
 Check for phone validity.
 
 isMaxLength ($string, $length)
 Check for string max length validity.
 
 isNotEmptyString ($string)
 Check for string not empty.
 
 isMinLength ($string, $length)
 Check for string min length validity.
 
 isUrl ($url)
 Check url validity.
 
 isDuration ($duration)
 Check Duration validity.
 
 isNumeric ($string)
 Check numeric validity.
 
 isBool ($bool)
 Check for boolean validity.
 
 isInDb ($values, $table, $col)
 Check for all values in db.
 
 isFetchableElement ($id, $element_type)
 Check for all values in db for an element.
 

Protected Member Functions

 clear ()
 Use to clear errors msg or other ghost vars.
 
 setError ($errMsg)
 Use to clear errors msg or other ghost vars.
 

Detailed Description

Class toolbox to validate values.

Definition at line 29 of file validate.class.php.

Constructor & Destructor Documentation

◆ __construct()

Validate::__construct ( $db,
$outputLang = null )

Constructor.

Parameters
DoliDB$dbDatabase handler
Translate$outputLangOutput lang for error

Definition at line 54 of file validate.class.php.

Member Function Documentation

◆ clear()

Validate::clear ( )
protected

Use to clear errors msg or other ghost vars.

Returns
void

Definition at line 78 of file validate.class.php.

◆ isBool()

Validate::isBool ( $bool)

Check for boolean validity.

Parameters
boolean$boolBoolean to validate
Returns
boolean Validity is ok or not

Definition at line 253 of file validate.class.php.

◆ isDuration()

Validate::isDuration ( $duration)

Check Duration validity.

Parameters
mixed$durationto validate
Returns
boolean Validity is ok or not

Definition at line 223 of file validate.class.php.

◆ isEmail()

Validate::isEmail ( $email,
$maxLength = 0 )

Check for e-mail validity.

Parameters
string$emaile-mail address to validate
int$maxLengthstring max length (not used)
Returns
boolean Validity is ok or not

Definition at line 101 of file validate.class.php.

◆ isFetchableElement()

Validate::isFetchableElement ( $id,
$element_type )

Check for all values in db for an element.

See also
self\isFetchable()
Parameters
integer$idof element
string$element_typethe element type
Returns
boolean Validity is ok or not
Exceptions
Exception

Definition at line 350 of file validate.class.php.

References $id, and getElementProperties().

◆ isInDb()

Validate::isInDb ( $values,
$table,
$col )

Check for all values in db.

Parameters
string[]$valuesBoolean to validate
string$tablethe db table name without $this->db->prefix()
string$colthe target col
Returns
boolean Validity is ok or not
Exceptions
Exception

Definition at line 271 of file validate.class.php.

◆ isMaxLength()

Validate::isMaxLength ( $string,
$length )

Check for string max length validity.

Parameters
string$stringto validate
int$lengthmax length
Returns
boolean Validity is ok or not

Definition at line 162 of file validate.class.php.

◆ isMinLength()

Validate::isMinLength ( $string,
$length )

Check for string min length validity.

Parameters
string$stringto validate
int$lengthmax length
Returns
boolean Validity is ok or not

Definition at line 193 of file validate.class.php.

◆ isNotEmptyString()

Validate::isNotEmptyString ( $string)

Check for string not empty.

Parameters
string$stringto validate
Returns
boolean Validity is ok or not

Definition at line 177 of file validate.class.php.

◆ isNumeric()

Validate::isNumeric ( $string)

Check numeric validity.

Parameters
mixed$stringto validate
Returns
boolean Validity is ok or not

Definition at line 238 of file validate.class.php.

◆ isPhone()

Validate::isPhone ( $phone)

Check for phone validity.

Parameters
string$phonePhone string to validate
Returns
boolean Validity is ok or not

Definition at line 146 of file validate.class.php.

◆ isPrice()

Validate::isPrice ( $price)

Check for price validity.

Parameters
string$pricePrice to validate
Returns
boolean Validity is ok or not

Definition at line 116 of file validate.class.php.

◆ isTimestamp()

Validate::isTimestamp ( $stamp)

Check for timestamp validity.

Parameters
string | int$stamptimestamp to validate
Returns
boolean Validity is ok or not

Definition at line 131 of file validate.class.php.

◆ isUrl()

Validate::isUrl ( $url)

Check url validity.

Parameters
string$urlto validate
Returns
boolean Validity is ok or not

Definition at line 208 of file validate.class.php.

◆ setError()

Validate::setError ( $errMsg)
protected

Use to clear errors msg or other ghost vars.

Parameters
string$errMsgyour error message
Returns
void

Definition at line 89 of file validate.class.php.


The documentation for this class was generated from the following file: