Merge branch '15.0' of git@github.com:Dolibarr/dolibarr.git into 15.0

This commit is contained in:
Laurent Destailleur 2022-01-23 18:53:50 +01:00
commit 2985c03f9f
4 changed files with 22 additions and 7 deletions

View File

@ -400,8 +400,6 @@ print '</td>';
print '</tr>';
print '</table>';
print '</td></tr>';
print '</table>';
@ -538,6 +536,8 @@ if (!empty($_SESSION["commandbackuptorun"])) {
print "</div> <!-- end div center button -->\n";
print '</td></tr>';
print '</table>';
print "</div> <!-- end div fichehalfleft -->\n";

View File

@ -7595,7 +7595,7 @@ abstract class CommonObject
} else { return true; }
} elseif (in_array($type, array('double', 'real', 'price'))) {
// is numeric
if (!$validate->isDuration($fieldValue)) {
if (!$validate->isNumeric($fieldValue)) {
$this->setFieldError($fieldKey, $validate->error);
return false;
} else { return true; }

View File

@ -55,18 +55,17 @@ class Validate
{
global $langs;
if ($outputLang) {
if (empty($outputLang)) {
$this->outputLang = $langs;
} else {
$this->outputLang = $outputLang;
}
if (!is_object($this->outputLang) || !method_exists($outputLang, 'load')) {
if (!is_object($this->outputLang) || !method_exists($this->outputLang, 'load')) {
return false;
}
/** @var Translate $outputLang */
$outputLang->load('validate');
$this->outputLang->loadLangs(array('validate', 'errors'));
$this->db = $db;
}
@ -229,6 +228,21 @@ class Validate
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
*

View File

@ -315,6 +315,7 @@ RequireAtLeastXString = Requires at least %s character(s)
RequireXStringMax = Requires %s character(s) max
RequireAtLeastXDigits = Requires at least %s digit(s)
RequireXDigitsMax = Requires %s digit(s) max
RequireValidNumeric = Requires a numeric value
RequireValidEmail = Email address is not valid
RequireMaxLength = Length must be less than %s chars
RequireMinLength = Length must be more than %s char(s)