mirror of
https://github.com/e107inc/e107.git
synced 2025-08-01 20:30:39 +02:00
Validator handler: typos, debug info removed, small addition (default rule)
This commit is contained in:
@@ -9,9 +9,9 @@
|
|||||||
* Handler - general purpose validation functions
|
* Handler - general purpose validation functions
|
||||||
*
|
*
|
||||||
* $Source: /cvs_backup/e107_0.8/e107_handlers/validator_class.php,v $
|
* $Source: /cvs_backup/e107_0.8/e107_handlers/validator_class.php,v $
|
||||||
* $Revision: 1.7 $
|
* $Revision: 1.8 $
|
||||||
* $Date: 2009-06-12 20:41:34 $
|
* $Date: 2009-07-31 16:14:51 $
|
||||||
* $Author: e107steved $
|
* $Author: secretr $
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -75,9 +75,15 @@ class validatorClass
|
|||||||
{
|
{
|
||||||
global $tp, $pref;
|
global $tp, $pref;
|
||||||
$ret = array('data' => array(), 'failed' => array(), 'errors' => array());
|
$ret = array('data' => array(), 'failed' => array(), 'errors' => array());
|
||||||
|
|
||||||
foreach ($definitions as $dest => $defs)
|
foreach ($definitions as $dest => $defs)
|
||||||
{
|
{
|
||||||
$errNum = 0; // Start with no error
|
$errNum = 0; // Start with no error
|
||||||
|
|
||||||
|
if(!is_array($defs)) //default rule - dbClean -> toDB
|
||||||
|
{
|
||||||
|
$defs = array('dbClean', ($defs ? $defs : 'toDB'));
|
||||||
|
}
|
||||||
$src = varset($defs['srcName'],$dest); // Set source field name
|
$src = varset($defs['srcName'],$dest); // Set source field name
|
||||||
if (!isset($sourceFields[$src]))
|
if (!isset($sourceFields[$src]))
|
||||||
{
|
{
|
||||||
@@ -117,7 +123,7 @@ class validatorClass
|
|||||||
$newValue = trim(preg_replace($defs['stripChars'], "", $value));
|
$newValue = trim(preg_replace($defs['stripChars'], "", $value));
|
||||||
if ($newValue <> $value)
|
if ($newValue <> $value)
|
||||||
{
|
{
|
||||||
echo "Invalid: {$newValue} :: {$value}<br />";
|
//echo "Invalid: {$newValue} :: {$value}<br />";
|
||||||
$errNum = ERR_INVALID_CHARS;
|
$errNum = ERR_INVALID_CHARS;
|
||||||
}
|
}
|
||||||
$value = $newValue;
|
$value = $newValue;
|
||||||
@@ -144,11 +150,11 @@ class validatorClass
|
|||||||
$errNum = ERR_TOO_LONG;
|
$errNum = ERR_TOO_LONG;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!$errnum && isset($defs['minVal']) && ($value < $defs['minVal']))
|
if (!$errNum && isset($defs['minVal']) && ($value < $defs['minVal']))
|
||||||
{
|
{
|
||||||
$errNum = ERR_TOO_LOW;
|
$errNum = ERR_TOO_LOW;
|
||||||
}
|
}
|
||||||
if (!$errnum && isset($defs['maxVal']) && ($value < $defs['maxVal']))
|
if (!$errNum && isset($defs['maxVal']) && ($value < $defs['maxVal']))
|
||||||
{
|
{
|
||||||
$errNum = ERR_TOO_HIGH;
|
$errNum = ERR_TOO_HIGH;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user