Issues

ZF-2453: Behaviour of Zend_Validate_Input messages is not intuitive

Issue Type: Docs: Improvement Created: 2008-01-18T04:07:27.000+0000 Last Updated: 2009-08-27T14:54:58.000+0000 Status: Resolved Fix version(s): - 1.10.0 (27/Jan/10)

Reporter: Ian Lewis (electricowl) Assignee: Thomas Weidner (thomas) Tags: - Zend_Filter_Input

  • Zend_Validate

Related issues: Attachments:

Description

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

example:

<pre class="highlight">
$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:

<pre class="highlight">
$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

Comments

Posted by Wil Sinclair (wil) on 2008-04-18T16:55:02.000+0000

Please evaluate and categorize/assign as necessary.

Posted by Benjamin Eberlei (beberlei) on 2008-11-15T10:05:18.000+0000

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

Posted by Benjamin Eberlei (beberlei) on 2009-01-07T16:49:55.000+0000

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

Posted by Ralph Schindler (ralph) on 2009-01-10T11:04:35.000+0000

reassigning, matthew ideas?

Posted by Thomas Weidner (thomas) on 2009-08-27T14:54:11.000+0000

I just tested this...

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

<pre class="highlight">
        $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')
        );

Posted by Thomas Weidner (thomas) on 2009-08-27T14:54:58.000+0000

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

Have you found an issue?

See the Overview section for more details.

Copyright

© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts