1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-05 14:17:49 +02:00

Validator 'enum' type added

This commit is contained in:
secretr
2010-03-01 10:20:25 +00:00
parent 17e69f0f66
commit 6d57b1f5bf

View File

@@ -80,7 +80,7 @@ class e_validator
const ERR_INVALID_EMAIL = 104;
/**
* @var integer Invalid email error code
* @var integer Field doesn't match error code
*/
const ERR_FIELDS_MATCH = 105;
@@ -176,6 +176,7 @@ class e_validator
* - required | no condition required
* - callback | string function name or array(class name|object, method) (static call)
* - instanceof | string class name
* - enum | (string) values separated by '#' e.g. 'match1#match2#match3'
* - array | array count range in format 'min:max'
* - compare | string field_name, value should be in format field_name => array('value1', 'value1')
* if value1 === value1, field_name => value1 will be added to $_valid_data array
@@ -555,6 +556,18 @@ class e_validator
return true;
break;
case 'enum':
$tmp = explode('#', $cond);
if(!$value || !in_array($value, $tmp))
{
$this->addValidateResult($name, self::ERR_FIELDS_MATCH);
return false;
}
$this->addValidData($name, (string) $value);
return true;
break;
case 'float':
if(!is_numeric($value))
{