bobthecow / Ruler

A simple stateless production rules engine for modern PHP
MIT License
1.06k stars 140 forks source link

What do you think of using this as a input validation tool? #27

Closed CMCDragonkai closed 10 years ago

CMCDragonkai commented 10 years ago

I'm thinking of integrating this into a input validation tool, most validation tools are usually based on configuration rather than code.

bobthecow commented 10 years ago

I haven't used it as such, but I could see it working well.

Ruler is great at "business rule validation", which I'd consider a distinct problem from "input validation". It may be semantics, but I think it's a useful distinction to make :)

Consider the difference between "You must enter a valid phone number", and "You must enter either a cell phone number OR (an office phone number AND a home phone number)". The former would probably be best suited to a standard input validation library because it's a pattern matching problem. You could easily write (or copy/paste) a regex that validates all phone numbers you accept. The latter, however, would be a great fit for Ruler, because it's a complex set of requirements rather than just a pattern.

CMCDragonkai commented 10 years ago

That flexibility is precisely what I'm looking for. Because often input validation has business rules that have logic extending from prior logic.