Issue Type: New Feature Created: 2009-09-24T19:40:03.000+0000 Last Updated: 2009-09-25T04:07:38.000+0000 Status: Resolved Fix version(s): - 1.10.0 (27/Jan/10)
Reporter: David Muir (dmuir) Assignee: Thomas Weidner (thomas) Tags: - Zend_Validate
Related issues: Attachments:
It would be great to have a series of context sensitive validators.
Since the context isn't supported by regular validation chains, and used mainly by forms, maybe they should be under Zend_Form_Validate instead to reduce confusion, or does that just make it worse?
Some useful validators that would be great if they had context sensitive alternatives:
Db_RecordExists Db_NoRecordExists Between GreaterThan LessThan Identical NotEmpty Regex
Let me know if this should go through the proposal process instead.
Posted by Thomas Weidner (thomas) on 2009-09-25T00:15:41.000+0000
No, this is nonsense.
Validators themself should not take care of context. Context is only a way of Zend_Form to prevent problems on actual API of Zend_Form.
What should a identical validator for example to with a context ? Identical means that token and value are 100% identical. A context would only be usefull when it has to check only a part, which means that it would then no longer be identical but only partitial. Same goes for other validators.
And we can not add context to the interface as this would mean that all validators can not be used standalone anymore, or have problems when you change Zend_Forms API or extend it with a own implementation.
Actually there is already a proposal which aims to solve this problem because context was added a few months ago to Zend_Form.
Posted by Thomas Weidner (thomas) on 2009-09-25T00:17:26.000+0000
Closing as won't fix.
The existing proposal has another way to solve this problem, than extending all validators, or breaking the API. It will not create duplicate validators nor will it change existing validators.
Posted by David Muir (dmuir) on 2009-09-25T01:23:27.000+0000
I'm not proposing that all the validators be extended, as many of them don't make sense to validate against the context.
Here's an example of what a context sensitive Identical validator would look like (which would come in very handy with a registration form that asks you to enter the password twice):
<pre class="highlight"> $form->addElements(array( 'password' => array( 'type' => 'text', 'options' => array( 'label' => 'Password' ) ), 'password_confirm' => array( 'type' => 'text', 'options' => array( 'label' => 'Password Confirm', 'validators' => array( array('Identical', true, array('%password%')) ) ) ) ));
In this case, the token %password% gets replaced with the value from the password value in the context.
But as you say, there's a proposal that is supposed to fix all this. Could you provide a link to the proposal? I know Matthew is working on refactoring Zend_Form, but his proposal hasn't been updated in a year and a half, and the other proposals are much older.
Posted by David Muir (dmuir) on 2009-09-25T03:43:16.000+0000
Sorry, had a brain fart. Was looking for Zend_Form related proposals, not Zend_Validate. I'm assuming you're referring to Zend_Validate/Filter_Builder? (http://framework.zend.com/wiki/display/…) It does solve some issues, but would need to be supported by Zend_Form to make it applicable.
Have you found an issue?
See the Overview section for more details.