library/Garp/Model/Validator/Email.php
public function validate(array $data, Garp_Model_Db $model, $onlyIfAvailable = true) {
        $theColumns = $this->_fields;
        $regexp = self::EMAIL_REGEXP;
        $validate = function($c) use ($data, $onlyIfAvailable, $regexp) {
            if (
                $onlyIfAvailable &&
                (
                    !array_key_exists($c, $data) ||
                    empty($data[$c])
                )
            ) {
                return;
            }
            if (empty($data[$c]) || !preg_match($regexp, $data[$c])) {
                $value = !empty($data[$c]) ? $data[$c] : '';
                $error = sprintf(__("'%value%' is not a valid email address in the basic format local-part@hostname"), $value);
                throw new Garp_Model_Validator_Email_Exception($error);
            }
        };
        array_walk($theColumns, $validate);
    }
public function validate(array $data, Garp_Model_Db $model, $onlyIfAvailable = true) {
        $theColumns = $this->_fields;
        $regexp = self::EMAIL_REGEXP;
        $validate = function($c) use ($data, $onlyIfAvailable, $regexp) {
            if (
                $onlyIfAvailable &&
                (
                    !array_key_exists($c, $data) ||
                    empty($data[$c])
                )
            ) {
                return;
            }
            if (empty($data[$c]) || !preg_match($regexp, $data[$c])) {
                $value = !empty($data[$c]) ? $data[$c] : '';
                $error = sprintf(__("'%value%' is not a valid email address in the basic format local-part@hostname"), $value);
                throw new Garp_Model_Validator_Email_Exception($error);
            }
        };
        array_walk($theColumns, $validate);
    }
public function validate ( array $ data , Garp_Model_Db $ model , $ onlyIfAvailable = true ) { $ theColumns = $ this -> _fields ; $ regexp = self :: EMAIL_REGEXP ; $ validate = function ( $ c ) use ( $ data , $ onlyIfAvailable , $ regexp ) { if ( $ onlyIfAvailable && ( ! array_key_exists ( $ c , $ data ) || empty ( $ data [ $ c ] ) ) ) { return ; } if ( empty ( $ data [ $ c ] ) || ! preg_match ( $ regexp , $ data [ $ c ] ) ) { $ value = ! empty ( $ data [ $ c ] ) ? $ data [ $ c ] : '' ; $ error = sprintf ( __ ( "'%value%' is not a valid email address in the basic format local-part@hostname" ) , $ value ) ; throw new Garp_Model_Validator_Email_Exception ( $ error ) ; } } ; array_walk ( $ theColumns , $ validate ) ; }
Validate wether the given columns are not empty
@param Array $data The data to validate
@param Boolean $onlyIfAvailable Wether to skip validation on fields that are not in the array
@return Void
@throws Garp_Model_Validator_Exception
Validate wether the given columns are not empty