nathggns / Scaffold

Lightweight PHP API Framework
Other
8 stars 2 forks source link

Validate strict mode #18

Closed nathggns closed 12 years ago

nathggns commented 12 years ago

At the moment, if you write a rule, and test it with data missing for that rule, it just ignores it. For example:

<?php
$validator = new Validate();
$validator->set('name', 'alphanumeric');
$validator->set('password', 'alphanumeric');
$validator->test(array('name' => 'Foo'));

That will pass. I think we should have an option where you can say if the Validator should error at missing values, and for missing rules.

So now we have this:

<?php
$validator = new Validate();
$validator->strict = true;
$validator->set('name', 'alphanumeric');

$validator->test(array('email' => 'scaffold.is.awesome@gmail.com'));
// Will Fail

$validator->test(array(
    'name' => 'scaffold',
    'email' => 'scaffold.is.awesome@gmail.com',
    'password' => 'scaffold'
));
// Will Fail

P.S. Yes, I know the branch name is incorrectly spelt.

nathggns commented 12 years ago

Woops, did not mean for the patch1 commit to make it's way in. Please merge that pull request first.

ClaudioAlbertin commented 12 years ago

No, just add a rule for checking if something is given/not empty.

nathggns commented 12 years ago

We could have those as well as this, to be fair. I don't see any reason for not including this?

nathggns commented 12 years ago

Closed in favour of Issues #22 and #24