Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

@Annotation\ErrorMessage not used with Regex validator #4163

Closed
internalsystemerror opened this Issue Apr 1, 2013 · 2 comments

Comments

Projects
None yet
3 participants

When creating a form the following form annotations:


namespace Application\Form;

use Zend\Form\Annotation as Form;

class AnnotationForm
{
    /**
     * @Form\Name("formProperty")
     * @Form\Type("text")
     * @Form\Options({"label":"Custom form property"})
     * @Form\ErrorMessage("Custom Error Message - 6 digits required")
     * @Form\Validator({"name":"Regex", "options":{"pattern":"/^[\d]{6}$/"}})
     */
    private $formProperty;
}

The "ErrorMessage" property appears not be used and "The input does not match against pattern '/^[\d]{6}$/'" is given as the error message instead. Is this the expected output? In order to change the error message, I have to pass a new messages array as one of the validator options.

ise

You sould do something like this

/**
*  @Annotation\Validator({
"name":"Regex", 
"options":{"pattern":"/^[\d]{6}$/", 
      "messages":{
            "regexInvalid":"Regex is invalid!",
            "regexNotMatch": "Regex not match",
            "regexErrorous": "Internal error!"
       }
}
})
*/

@GeeH GeeH added the To Be Closed label Mar 5, 2016

GeeH commented Jun 27, 2016

This issue has been closed as part of the bug migration program as outlined here - http://framework.zend.com/blog/2016-04-11-issue-closures.html

@GeeH GeeH closed this Jun 27, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment