Validate email in switch

Hi all,

I want make validate email in “switch” but I have no idea what should be in my register.php after “=>”
And how should be looked correctly case “filtervar”.

Any ideas ?

PS.
username will be email

In register.php I have array username:

[php] $validate = new Validate();
$validation = $validate->check($_POST, array(
‘username’ => array(
‘required’ => true,
‘min’ => 2,
‘max’ => 50,
‘unique’ => ‘users’,
‘filtervar’ =>

		),[/php]

My validate.php

[php]if($rule === ‘required’ && empty($value)) {
$this->addError("{$item} is required");
} else if(!empty($value)){
switch($rule) {
case ‘min’:
if(strlen($value) < $rule_value) {
$this->addError("{$item} must be a minimum of {$rule_value} characters");
}
break;
case ‘max’:
if(strlen($value) > $rule_value) {
$this->addError("{$item} must be a maximum of {$rule_value} characters");
}
break;
case ‘matches’:
if($value != $source[$rule_value]) {
$this->addError("{$rule_value} must match {$item}");
}
break;
case ‘unique’:
$check = $this->_db->get($rule_value, array($item, ‘=’, $value));
if($check->count()) {
$this->addError("{$item} already exists");
}
break;

					case 'filtervar':
						if(filter_var($item FILTER_VALIDATE_EMAIL))
							
					break;

					
				}
			
			}

		}
	}[/php]

I’m not really sure what you are asking, but I know this portion is incorrect,
[php]filter_var($item FILTER_VALIDATE_EMAIL)[/php]

Length of username or required position i have in switch statement. And I want add email filter_var to this switch statement, but I don’t know how. Sorry Im begginer…

Sponsor our Newsletter | Privacy Policy | Terms of Service