Wixel / GUMP

A fast, extensible & stand-alone PHP input validation class that allows you to validate any data
https://wixelhq.com
MIT License
1.17k stars 341 forks source link

trigger error on too many POST fields #14

Closed roydekleijn closed 10 years ago

roydekleijn commented 10 years ago

Hello,

Can we also trigger an error if there are too many fields to validate?

Let's say we have 4 fields to validate, but only 3 rules are specified. This should trigger an error or the field without rule should be left out of the $gump->run($_POST) return array.

What do you think? or is it already possible? Roy

sn commented 10 years ago

Hi Roy,

What you mention in your message is not currently built into Gump, the reason for this is because some forms only need certain elements validated and not others - somewhat of a whitehat approach.

I am working on rebuilding Gump from the ground up to be more versatile, so I'm sure I can work in an option that would allow you to fail validation when form element counts don't match.

If you follow the project, I'll be sure to notify you with the update.

S

roydekleijn commented 10 years ago

Ok, thanks for your reply.

In the meantime I will implement it myself. (shouldn't be too difficult, array_diff_key() should do it);

Do you want a pull request for this ? Shall I put it to the run() function? (which can be set by parameter?)

Thanks, Roy

sn commented 10 years ago

Sure, you are welcome to submit a pull request once you have it working.

The run() method is probably the best place to start.

S

fas3r commented 6 years ago

@roydekleijn hello,

I know it's quite old but I'm looking for something similar, did you come up with a solution 👍 ?

thank you by advance.