57    if (empty($outputLang)) {
 
   58      $this->outputLang = $langs;
 
   60      $this->outputLang = $outputLang;
 
   63    if (!is_object($this->outputLang) || !method_exists($this->outputLang, 
'load')) {
 
   67    $this->outputLang->loadLangs(array(
'validate', 
'errors'));
 
 
   90    $this->error = $errMsg;
 
 
  100  public function isEmail($email, $maxLength = 
false)
 
  102    if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
 
  103      $this->error = $this->outputLang->trans(
'RequireValidEmail');
 
 
  117    if (!preg_match(
'/^[0-9]{1,10}(\.[0-9]{1,9})?$/ui', $price)) {
 
  118      $this->error = $this->outputLang->trans(
'RequireValidValue');
 
 
  132    if (!is_numeric($stamp) && (
int) $stamp == $stamp) {
 
  133      $this->error = $this->outputLang->trans(
'RequireValidDate');
 
 
  147    if (!preg_match(
'/^[+0-9. ()-]*$/ui', $phone)) {
 
  148      $this->error = $this->outputLang->trans(
'RequireValidPhone');
 
 
  163    if (strlen($string) > $length) {
 
  164      $this->error = $this->outputLang->trans(
'RequireMaxLength', $length);
 
 
  178    if (!strlen($string)) {
 
  179      $this->error = $this->outputLang->trans(
'RequireANotEmptyValue');
 
 
  194    if (strlen($string) < $length) {
 
  195      $this->error = $this->outputLang->trans(
'RequireMinLength', $length);
 
 
  209    if (!filter_var($url, FILTER_VALIDATE_URL)) {
 
  210      $this->error = $this->outputLang->trans(
'RequireValidUrl');
 
 
  224    if (!is_int($duration) && $duration >= 0) {
 
  225      $this->error = $this->outputLang->trans(
'RequireValidDuration');
 
 
  239    if (!is_numeric($string)) {
 
  240      $this->error = $this->outputLang->trans(
'RequireValidNumeric');
 
 
  254    if (!(is_null($bool) || is_bool($bool) || preg_match(
'/^[0|1]{1}$/ui', $bool))) {
 
  255      $this->error = $this->outputLang->trans(
'RequireValidBool');
 
 
  270  public function isInDb($values, $table, $col)
 
  272    if (!is_array($values)) {
 
  273      $value_arr = array($values);
 
  275      $value_arr = $values;
 
  278    if (!count($value_arr)) {
 
  279      $this->error = $this->outputLang->trans(
'RequireValue');
 
  283    foreach ($value_arr as $val) {
 
  284      $sql = 
"SELECT ".$col.
" FROM ".$this->db->prefix().$table.
" WHERE ".$col.
" = '".$this->db->escape($val).
"' LIMIT 1"; 
 
  285      $resql = $this->db->query($sql);
 
  287        $obj = $this->db->fetch_object($resql);
 
  293      $this->error = $this->outputLang->trans(
'RequireValidExistingElement');
 
 
  309  public function isFetchable($id, $classname, $classpath)
 
  311    if (!empty($classpath)) {
 
  313        if ($classname && class_exists($classname)) {
 
  315          $object = 
new $classname($this->db);
 
  317          if (!is_callable(array($object, 
'fetch')) || !is_callable(array($object, 
'isExistingObject'))) {
 
  318            $this->error = $this->outputLang->trans(
'BadSetupOfFieldFetchNotCallable');
 
  322          if (!empty($object->table_element) && $object->isExistingObject($object->table_element, $id)) {
 
  325            $this->error = $this->outputLang->trans(
'RequireValidExistingElement');
 
  328          $this->error = $this->outputLang->trans(
'BadSetupOfFieldClassNotFoundForValidation');
 
  331        $this->error = $this->outputLang->trans(
'BadSetupOfFieldFileNotFound');
 
  334      $this->error = $this->outputLang->trans(
'BadSetupOfField');
 
  352    return $this->isFetchable($id, $elementProperty[
'classname'], $elementProperty[
'classpath'].
'/'.$elementProperty[
'classfile'].
'.class.php');
 
 
 
Class toolbox to validate values.
isMinLength($string, $length)
Check for string min length validity.
isNotEmptyString($string)
Check for string not empty.
isNumeric($string)
Check numeric validity.
isDuration($duration)
Check Duration validity.
isInDb($values, $table, $col)
Check for all values in db.
isMaxLength($string, $length)
Check for string max length validity.
__construct($db, $outputLang=null)
Constructor.
clear()
Use to clear errors msg or other ghost vars.
isFetchableElement($id, $element_type)
Check for all values in db for an element.
setError($errMsg)
Use to clear errors msg or other ghost vars.
isPrice($price)
Check for price validity.
isBool($bool)
Check for boolean validity.
isTimestamp($stamp)
Check for timestamp validity.
isEmail($email, $maxLength=false)
Check for e-mail validity.
isPhone($phone)
Check for phone validity.
isUrl($url)
Check url validity.
if(!function_exists( 'dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
getElementProperties($element_type)
Get an array with properties of an element.