library/Garp/Util/SimpleMail.php
public function isValid(array $requiredFields = array()) {
        // check if all values required to send the mail are set
        if (empty($this->_params['body'])
            || empty($this->_params['from'])
            || empty($this->_params['to'])
            || empty($this->_params['subject'])
        ) {
            $this->addError('Not all required mail parameters were given.');
            return false;
        }

        // check that at least 1 second passed from form rendering to form submit
        if (array_key_exists(self::TIMESTAMP_KEY, $this->_postParams)
            && time()-$this->_postParams[self::TIMESTAMP_KEY] <= 1
        ) {
            $this->addError('Timestamp difference is less than or equal to 1 second.');
            return false;
        }

        // check if the honeypot was filled
        if (array_key_exists(self::HONEYPOT_KEY, $this->_postParams)
            && !empty($this->_postParams[self::HONEYPOT_KEY])
        ) {
            $this->addError('Honeypot was filled.');
            return false;
        }

        // check if all required fields were filled
        foreach ($requiredFields as $field) {
            if (empty($this->_postParams[$field])) {
                $this->addError('Required field ' . $field . ' is empty.');
                return false;
            }
        }
        return true;
    }
public function isValid(array $requiredFields = array()) {
        // check if all values required to send the mail are set
        if (empty($this->_params['body'])
            || empty($this->_params['from'])
            || empty($this->_params['to'])
            || empty($this->_params['subject'])
        ) {
            $this->addError('Not all required mail parameters were given.');
            return false;
        }

        // check that at least 1 second passed from form rendering to form submit
        if (array_key_exists(self::TIMESTAMP_KEY, $this->_postParams)
            && time()-$this->_postParams[self::TIMESTAMP_KEY] <= 1
        ) {
            $this->addError('Timestamp difference is less than or equal to 1 second.');
            return false;
        }

        // check if the honeypot was filled
        if (array_key_exists(self::HONEYPOT_KEY, $this->_postParams)
            && !empty($this->_postParams[self::HONEYPOT_KEY])
        ) {
            $this->addError('Honeypot was filled.');
            return false;
        }

        // check if all required fields were filled
        foreach ($requiredFields as $field) {
            if (empty($this->_postParams[$field])) {
                $this->addError('Required field ' . $field . ' is empty.');
                return false;
            }
        }
        return true;
    }
public function isValid ( array $ requiredFields = array ( ) ) { // check if all values required to send the mail are set if ( empty ( $ this -> _params [ 'body' ] ) || empty ( $ this -> _params [ 'from' ] ) || empty ( $ this -> _params [ 'to' ] ) || empty ( $ this -> _params [ 'subject' ] ) ) { $ this -> addError ( 'Not all required mail parameters were given.' ) ; return false ; } // check that at least 1 second passed from form rendering to form submit if ( array_key_exists ( self :: TIMESTAMP_KEY , $ this -> _postParams ) && time ( ) - $ this -> _postParams [ self :: TIMESTAMP_KEY ] <= 1 ) { $ this -> addError ( 'Timestamp difference is less than or equal to 1 second.' ) ; return false ; } // check if the honeypot was filled if ( array_key_exists ( self :: HONEYPOT_KEY , $ this -> _postParams ) && ! empty ( $ this -> _postParams [ self :: HONEYPOT_KEY ] ) ) { $ this -> addError ( 'Honeypot was filled.' ) ; return false ; } // check if all required fields were filled foreach ( $ requiredFields as $ field ) { if ( empty ( $ this -> _postParams [ $ field ] ) ) { $ this -> addError ( 'Required field ' . $ field . ' is empty.' ) ; return false ; } } return true ; }
Check if the submitted data is valid

@param Array $requiredFields
@return Boolean description
Check if the submitted data is valid