Zend Framework

Behaviour of Zend_Validate_Input messages is not intuitive

Details

  • Type: Docs:  Improvement Docs: Improvement
  • Status: Resolved Resolved
  • Priority: Minor Minor
  • Resolution: Fixed
  • Affects Version/s: 1.0.2
  • Fix Version/s: 1.10.0
  • Labels:
    None

Description

Get error Zend_Validate_Exception: No message template exists for key '' when attempting the intuitive approach:

example:

$validators = array(
    'month' => array(
        'alpha',
        'messages' => 'A month must consist only of letters'
    ),
 'year' => array(
        'digits',
        'messages' => 'A year must consist only of numbers'
    )
);

Closer reading of the docs suggests that the following works:

example:

$validators = array(
    'month' => array(
        'alpha'
    ),
 'year' => array(
        'digits'
    ),
 'messages'  => array ( 
         1  =>  'A month must consist only of letters',
         2  =>  'A year must consist only of numbers' 
     )
);

Also, if this interpretation is correct what approach should one adopt if there is a form field called 'messages'.

Thanks,
Ian Lewis

Activity

Hide
Wil Sinclair added a comment -

Please evaluate and categorize/assign as necessary.

Show
Wil Sinclair added a comment - Please evaluate and categorize/assign as necessary.
Hide
Benjamin Eberlei added a comment -

This issue is also an issue of Zend_Filter_Input as far as i understood it. Recategorized.

Show
Benjamin Eberlei added a comment - This issue is also an issue of Zend_Filter_Input as far as i understood it. Recategorized.
Hide
Benjamin Eberlei added a comment -

This is more a problem of the bad API of complex Zend_Filter_Input objects.

The solution to this problem is more of a documentation issue (of the bad API). Changes are only possible for 2.0

Show
Benjamin Eberlei added a comment - This is more a problem of the bad API of complex Zend_Filter_Input objects. The solution to this problem is more of a documentation issue (of the bad API). Changes are only possible for 2.0
Hide
Ralph Schindler added a comment -

reassigning, matthew ideas?

Show
Ralph Schindler added a comment - reassigning, matthew ideas?
Hide
Thomas Weidner added a comment -

I just tested this...

Actually both approaches are usable. Within the testbed the following is checked and works:

$validators = array(
            'name' => array('NotEmpty','messages' => 'Please enter your name'),
            'subject' => array('NotEmpty','messages' => 'Please enter a subject'),
            'email' => array('EmailAddress','messages' => 'Please enter a valid Email address'),
            'content' => array('NotEmpty','messages' => 'Please enter message contents')
        );
Show
Thomas Weidner added a comment - I just tested this... Actually both approaches are usable. Within the testbed the following is checked and works:
$validators = array(
            'name' => array('NotEmpty','messages' => 'Please enter your name'),
            'subject' => array('NotEmpty','messages' => 'Please enter a subject'),
            'email' => array('EmailAddress','messages' => 'Please enter a valid Email address'),
            'content' => array('NotEmpty','messages' => 'Please enter message contents')
        );
Hide
Thomas Weidner added a comment -

Seems to be fixed with one of the previous commits.
Therefor closing this issue as fixed with the next minor release.

Show
Thomas Weidner added a comment - Seems to be fixed with one of the previous commits. Therefor closing this issue as fixed with the next minor release.

People

Vote (0)
Watch (2)

Dates

  • Created:
    Updated:
    Resolved: