Issues

ZF-2433: Add accessors to Zend_Validate_Abstract to make l10n/i18n possible

Issue Type: Improvement Created: 2008-01-14T13:26:36.000+0000 Last Updated: 2008-03-21T16:25:20.000+0000 Status: Resolved Fix version(s): - 1.5.0 (17/Mar/08)

Reporter: Matthew Weier O'Phinney (matthew) Assignee: Darby Felton (darby) Tags: - Zend_Validate

Related issues: Attachments:

Description

Currently, it's next-to-impossible to localize validation error messages with concrete validators extending Zend_Validate_Abstract. I propose adding the following methods:

<pre class="highlight">
class Zend_Validate_Abstract implements Zend_Validate_Interface
{
    /**
     * Set value which caused validation failure
     */
    public function setValue($value);

    /**
     * Retrieve value causing validation failure
     */
    public function getValue();

    /**
     * Set custom template for a given validation error code
     */
    public function setMessageTemplate($code, $template);

    /**
     * Set custom templates for multiple error codes 
     * (code => template pairs)
     */
    public function setMessageTemplates(array $templates);

    /**
     * Retrieve message template for given code
     */
    public function getMessageTemplate($code);

    /**
     * Retrieve all message template (code => template pairs)
     */
    public function getMessageTemplates();

    /**
     * Set translation adapter to use when generating messages
     */
    public function setTranslator(Zend_Translate_Adapter $translator);

    /**
     * Get translation adapter
     */
    public function getTranslator();
}

Furthermore, if a translation adapter is present, validators shipped with Zend Framework should use it to translate the current message into the current locale when setting validation error messages.

These enhancements would greatly enhance validators by allowing for custom messages as well as localized messages.

Comments

Posted by Darby Felton (darby) on 2008-02-08T13:01:08.000+0000

Translation of validation messages has already been implemented. Resolving as Fixed for next minor release. Please reopen and/or otherwise modify if I am mistaken. :)

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