Skip to content

required input - unable to set custom isEmpty message #2

New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
j-schumann opened this issue Mar 11, 2016 · 2 comments
Closed

required input - unable to set custom isEmpty message #2

j-schumann opened this issue Mar 11, 2016 · 2 comments

Comments

@j-schumann
Copy link
Owner

When using an inputSpecification using required=true we could use a notEmpty validator in the chain to set our custom error message when the input was not set:

return [
            'name'     => $this->getName(),
            'required' => true,
            'filters'  => [
                ['name' => 'Zend\Filter\StringTrim'],
            ],
            'validators' => [
                [
                    'name'                   => 'Zend\Validator\NotEmpty',
                    'break_chain_on_failure' => true,
                    'options'                => [
                        'messages' => [
                            \Zend\Validator\NotEmpty::IS_EMPTY => 'custom message',
                        ],
                    ],
                ],
                // further validators
            ],
        ];

InputFilter would then use this validator to get the error message. But now Zend\InputFilter\Input uses prepareRequiredValidationFailureMessage() the default NotEmpty::IS_EMPTY message without any option to customize this.
There is a pull request open to fix this zendframework/zend-inputfilter#73 but it is not merged yet while other solutions are discussed...

j-schumann added a commit that referenced this issue Mar 11, 2016
@j-schumann
Copy link
Owner Author

seems fixed on ZF side since 2.6.1 - 2016-04-07 -> fix here

@j-schumann
Copy link
Owner Author

fixed in CSRF-Element

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant