Merge pull request #19836 from atm-john/15.0_fix_validate_lang_and_test
FIX : lang load in validate class and fix test for numeric values
This commit is contained in:
commit
307338e3f4
@ -7595,7 +7595,7 @@ abstract class CommonObject
|
|||||||
} else { return true; }
|
} else { return true; }
|
||||||
} elseif (in_array($type, array('double', 'real', 'price'))) {
|
} elseif (in_array($type, array('double', 'real', 'price'))) {
|
||||||
// is numeric
|
// is numeric
|
||||||
if (!$validate->isDuration($fieldValue)) {
|
if (!$validate->isNumeric($fieldValue)) {
|
||||||
$this->setFieldError($fieldKey, $validate->error);
|
$this->setFieldError($fieldKey, $validate->error);
|
||||||
return false;
|
return false;
|
||||||
} else { return true; }
|
} else { return true; }
|
||||||
|
|||||||
@ -55,18 +55,17 @@ class Validate
|
|||||||
{
|
{
|
||||||
global $langs;
|
global $langs;
|
||||||
|
|
||||||
if ($outputLang) {
|
if (empty($outputLang)) {
|
||||||
$this->outputLang = $langs;
|
$this->outputLang = $langs;
|
||||||
} else {
|
} else {
|
||||||
$this->outputLang = $outputLang;
|
$this->outputLang = $outputLang;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!is_object($this->outputLang) || !method_exists($outputLang, 'load')) {
|
if (!is_object($this->outputLang) || !method_exists($this->outputLang, 'load')) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @var Translate $outputLang */
|
$this->outputLang->loadLangs(array('validate', 'errors'));
|
||||||
$outputLang->load('validate');
|
|
||||||
|
|
||||||
$this->db = $db;
|
$this->db = $db;
|
||||||
}
|
}
|
||||||
@ -229,6 +228,21 @@ class Validate
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check numeric validity
|
||||||
|
*
|
||||||
|
* @param mixed $string to validate
|
||||||
|
* @return boolean Validity is ok or not
|
||||||
|
*/
|
||||||
|
public function isNumeric($string)
|
||||||
|
{
|
||||||
|
if (!is_numeric($string)) {
|
||||||
|
$this->error = $this->outputLang->trans('RequireValidNumeric');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check for boolean validity
|
* Check for boolean validity
|
||||||
*
|
*
|
||||||
|
|||||||
@ -315,6 +315,7 @@ RequireAtLeastXString = Requires at least %s character(s)
|
|||||||
RequireXStringMax = Requires %s character(s) max
|
RequireXStringMax = Requires %s character(s) max
|
||||||
RequireAtLeastXDigits = Requires at least %s digit(s)
|
RequireAtLeastXDigits = Requires at least %s digit(s)
|
||||||
RequireXDigitsMax = Requires %s digit(s) max
|
RequireXDigitsMax = Requires %s digit(s) max
|
||||||
|
RequireValidNumeric = Requires a numeric value
|
||||||
RequireValidEmail = Email address is not valid
|
RequireValidEmail = Email address is not valid
|
||||||
RequireMaxLength = Length must be less than %s chars
|
RequireMaxLength = Length must be less than %s chars
|
||||||
RequireMinLength = Length must be more than %s char(s)
|
RequireMinLength = Length must be more than %s char(s)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user