Hello,
I´ve tested your version and now my validator works fine but the problem is
that now the NotEmpty Validator doesn´t work any longer. If the value of
username is empty, the allowEmpty method doesn´t react and so the user could
have an empty username and that´s not how it should be^^
I hope you understand what I mean :)
Nilson
SiCo007 wrote:
>
> Hi, I've had a quick look and it doesn't look like you specify your
> validator in the correct place in the array:
>
> $validators = array(
> 'username' => array(
> 'allowEmpty' => false,
> 'Exists' => array(
> 'table' => 'user',
> 'name' => 'username'),
> 'breakChainOnFailure' => true,
> 'messages' => array(
> Nilson_Validate_Exists::EXISTS => 'Username existiert bereits'
> )
> ),............
>
> If I remember rightly the validator needs to come first, and with an
> object you instantiate it first (although there are other ways too)...
> Then make $exists ($exists being your validator) the first entry in the
> array before specifying the parameters for the validation.
>
> $exists = new Nilson_Validate_Exists('user', 'username');
>
> $validators = array(
> 'username' => array($exists,
> 'allowEmpty' => false,
> 'breakChainOnFailure' => true,
> 'messages' => array(
> Nilson_Validate_Exists::EXISTS => 'Username existiert bereits'
> )
> ),............
>
> Sorry the formatting is non existant but I hope it helps, also it's
> untested but I think I'm right. I've just done a very similiar validator
> to check for unique values in the table which I can send you if you like.
>
> Simon
>
>
> Nilson wrote:
>>
>> Hello everyone,
>>
>> I´ve written a Validator that checks if a given value is already in the
>> database.
>> I tested the Validator a few times and im sure that he works fine.
>> When i use the validator like the following it works fine and i get the
>> error....
>>
>> $peter = new Zend_Validate_Exists(array('name' => 'username', 'table' =>
>> 'user'));
>> $peter->isValid($this->_request->getParam('username'));
>> Zend_Debug::dump($peter);
>>
>> But if I use the Validator with Zend_Filter_input I don´t get the Error
>> if the value is already in the Database.
>>
>> Here is the Code how I use the Validator and the Code of the Validator.
>>
>> http://www.nabble.com/file/p14147565/Zend_Filter_Input_Issue_Nabble.php
>> Zend_Filter_Input_Issue_Nabble.php
>>
>> I hope you could understand my problem and perhaps that problem is
>> already known :)
>>
>> Greetings Nilson
>>
>
>
--
View this message in context:
http://www.nabble.com/Own-Validators-for-Zend_Filter_Input-tf4942091s16154.html#a14175994
Sent from the Zend Core mailing list archive at Nabble.com.
|
|