gajus / vlad

Input validation library promoting succinct syntax with extendable validators and multilingual support.
Other
104 stars 8 forks source link

Password #5

Open filhodanuvem opened 10 years ago

filhodanuvem commented 10 years ago

Hi @gajus ! My first thought about input filters would be case of "passwords". So, We could talk about it. I Think that just with a new validator isEqual anyone could write a passwords validation.

Eg.:

<?php
$test
    ->assert('user[password]')
    ->is('String')
    ->is('NotEmpty')
    ->is('LengthMin', ['length' => 6])
    ->is('LengthMax', ['length' => 10])
    ->is('Equal', ['field' => 'user[password_2]'] );

Questions:

:cloud:

gajus commented 10 years ago

This validator has been part of the package in v0.1.0. It has been removed because Validator interface has changed. New interface does not allow to pass Input haystack to the validator. However, I am sure that the value can be retrieved at the time of constructing the condition. Alternatively, why not pass the value itself? eg.,

$test = new \Gajus\Vlad\Test();
$test->assert('foo')->is('Equal', ['to' => $input['bar']);
filhodanuvem commented 10 years ago

I think that to test a POST request, for exemple, would more simple write something like that:

$test->assert('user[password]')->is('Equal', ['field' => 'user[password_2]'] );
// I use $_POST just once 
$test->assess($_POST); 

But, I understood what you said and we could use the value itself.

gajus commented 10 years ago

@cloudson you are right. That's how you'd use it. "foo" in my example is not password, it is the selector.