ZF-3178: Two more Standard Validator needed
Description
When validating register form, two validations are always needed:
1) Check user name availability 2) Check password and re enter password(or emails) matching
Christer has done 2) in his blog: http://cogo.wordpress.com/2008/04/…
I have done 1) in my project as a custom validator.
But I think it is nice that these two validators could be ship with ZF as standard validator.
Comments
Posted by Christer Edvartsen (cogo) on 2008-04-26T02:40:19.000+0000
To implement 1) you would need to have some sort of interface that the end users of ZF would have to implement though. It's impossible to make a generic validator for that since pretty much everyone has their own setup regarding user accounts.
I have implemented something like that but the class I have written will only work for my setup. If you could make a generic validator along with a small interface with a single method:
public function isTaken($userName);
or something like that, I guess it could be more simple to use. But 2) would be great to have in ZF I think.
Posted by Jason Qi (jason qi) on 2008-04-26T14:38:41.000+0000
For 1), What I did is writing a custom validator, similar with other validators.
The end user can use it without any difference to other validators. i.g. AddValidator('CheckAvailability' , false, array('user', 'username')). Where the 'user' is the table name and 'username' is the field name in the table.
In isValid($value) function, just check if there is a record in table 'user' and the value of field 'username' match $value.
And you are right, this is just for "DB Table Adapter", but I believe there should be a solution to combine other adapters together.
Posted by Wil Sinclair (wil) on 2008-06-09T12:42:07.000+0000
Please evaluate and fix/categorize as necessary.
Posted by Thomas Weidner (thomas) on 2009-03-31T23:49:27.000+0000
For DB there is a validator within the incubator almost finished and probably ready for 1.8. For the second "password" matching you should eighter use the Identical (incubator) or InArray validator. Both can compare form element values with a given string.
Posted by Thomas Weidner (thomas) on 2009-03-31T23:50:47.000+0000
Closing as non-issue as for both already solution are ready or almost finished and independently proposed.