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 28 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 53 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 77 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 252 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 222 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 100 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 348 of file validate.class.php.

References getElementProperties().

◆ isInDb()

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

Check for all values in db.

Parameters
array$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 270 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 161 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 192 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 176 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 237 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 145 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 115 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 130 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 207 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 88 of file validate.class.php.


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