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

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.

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.

Please evaluate and fix/categorize as necessary.

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.

Closing as non-issue as for both already solution are ready or almost finished and independently proposed.