for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php /** MicroEmailValidator */
namespace Micro\Validator;
use Micro\Form\IFormModel;
/**
* EmailValidator class file.
*
* @author Oleg Lunegov <[email protected]>
* @link https://github.com/linpax/microphp-framework
* @copyright Copyright (c) 2013 Oleg Lunegov
* @license https://github.com/linpax/microphp-framework/blob/master/LICENSE
* @package Micro
* @subpackage Validator
* @version 1.0
* @since 1.0
*/
class EmailValidator extends BaseValidator
{
* @inheritdoc
public function validate(IFormModel $model)
foreach ($this->elements AS $element) {
if (!$model->checkAttributeExists($element)) {
$this->errors[] = 'Parameter '.$element.' not defined in class '.get_class($model);
return false;
}
if (!filter_var($model->$element, FILTER_VALIDATE_EMAIL)) {
$this->errors[] = 'Parameter '.$element.' is not a valid E-mail address';
return true;
public function client(IFormModel $model)
return 'if (/^[\w.-]{1,}@[\w.-]{1,}$/.test(this.value) != true) {'.
' e.preventDefault(); this.focus(); alert(\'Value is not a valid e-mail\'); }';