Welcome, Guest. Register Now!
   
Mark Forums Read Mark Forums Read Mark Forums Read


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-27-2008, 01:32 AM
Junior Member
 
Join Date: Feb 2008
Posts: 1
Default Getting Errors using Zend_Filter_Input

Hi,

I'm trying to get the errors using Zend_Filter_Input but I have a filling that its a little bit complex or I missed something simple

My code
PHP Code:
class object
{
             
//bla-bla-bla 

    
public function update_data()
    {
        
$this->_setFilter();
        
$this->_setValidator();
        
$options = array('escapeFilter' => array('StringTrim','HtmlEntities'));
        
$input = new Zend_Filter_Input($this->_filter$this->_validator);
        
$input->setData($_POST);
        
$input->setOptions($options);
        if(
$input->isValid()){
            return 
true;
        }
        return 
false;
    }

    private function 
_setFilter()
    {
        
$this->_filter = array (
            
'Location' => new NZTA_Filter_UppercaseWords(),
            
'CategoryID' => 'Digits',
            
'Title' => new NZTA_Filter_UppercaseWords(),
            
'WebsiteLink' => new NZTA_Filter_EmptyJustHttp(),
            
'ContactName' => new NZTA_Filter_UppercaseWords(),
            
'ContactEmail' => 'StringToLower',
        );
    }

    private function 
_setValidator()
    {
        
$this->_validator = array(
            
'Location' => array('NotEmpty', new Zend_Validate_StringLength(self::MINLENGTH,self::MAXLENGTH)),
            
'CategoryID' => array('Digits', new NZTA_Validate_InNoticeCategoryArray($this->categories)),
            
'Title' => array('NotEmpty', new Zend_Validate_StringLength(self::MINLENGTH,self::MAXLENGTH)),
            
'Description' => array('NotEmpty', new NZTA_Validate_UrlNotAllowed()),
            
'WebsiteLink' => new Zend_Validate_StringLength(0,self::MAXLENGTH),
            
'ContactName' => array('NotEmpty', new Zend_Validate_StringLength(self::MINLENGTH,self::MAXLENGTH)),
            
'ContactEmail' => array('NotEmpty''EmailAddress'),
        );
    }


I have an Error static class where I set the errors: Error::setError($errMessege) OR Error::setErrors(array), where array(errID=>errMsg)

To get the errors I use
PHP Code:
$errors $input->getErrors(); 
Output
PHP Code:
Array
(
    [
Location] => Array
        (
            [
0] => isEmpty
            
[1] => stringLengthTooShort
        
)

    [
Title] => Array
        (
            [
0] => isEmpty
            
[1] => stringLengthTooShort
        
)

    [
Description] => Array
        (
            [
0] => isEmpty
        
)

Nop, these are NOT errors. Ok, what else
PHP Code:
$message $input->getMessages(); 
Output
PHP Code:
Array
(
    [
Location] => Array
        (
            [
isEmpty] => Value is empty, but a non-empty value is required
            
[stringLengthTooShort] => '' is less than 5 characters long
        
)

    [
Title] => Array
        (
            [
isEmpty] => Value is empty, but a non-empty value is required
            
[stringLengthTooShort] => '' is less than 5 characters long
        
)

    [
Description] => Array
        (
            [
isEmpty] => Value is empty, but a non-empty value is required
        
)

Ok, looks like I got ones. I think this is a wrong error format output. How I can get them without coding loops, I want something simple.

Is it possible?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 09:43 AM.