dbo Posted August 8, 2007 Share Posted August 8, 2007 I've just recently finished a project that required 60-80 fields per page on 8-10 forms and had to hand write javascript and php validation for this. I had written some libraries to assist in this... but even then it's a lot of work. So it got me thinking... there's got to be a much better way to do this. And so it began..... The idea is to have a way to seperate business rules and validation rules from programming logic and have a shared set of rules for both php and javascript. Here is a code snipet to show you how much time/coding this type of framework could save you. I'm still in the early stages of development and have some issues to work through but this should give you the idea. include_once "xml_rule_validator.php"; $xrv = new XMLRuleValidator(); $xrv->load_from_file("xml_validation_rules.xml"); $valid = $xrv->validate_php(); if( !$valid ) { $xrv->display_error_summary(); } And that's it... it would validate all get/session/post variables as specified in the xml document. So if you want to add or remove a check from a field... you make a simple change to an xml document rather than going in and hunting through lines of code. In my case I've got hundreds and hundreds of lines of code per page down to something like that. So what are your guys thoughts? Do you have different alternatives that you think are better? Any improvements upon my idea? Quote Link to comment https://forums.phpfreaks.com/topic/63846-input-validation/ Share on other sites More sharing options...
btherl Posted August 8, 2007 Share Posted August 8, 2007 Sounds like a good idea Go for it! Quote Link to comment https://forums.phpfreaks.com/topic/63846-input-validation/#findComment-318237 Share on other sites More sharing options...
chronister Posted August 8, 2007 Share Posted August 8, 2007 This kind of thing would be very handy. I am geared up to tackle about 4-6 forms with ~40 or so fields in each and I am not looking forward to it It is one of the most tedious aspects of PHP and using forms I look forward to seeing it when it is all done. Nate Quote Link to comment https://forums.phpfreaks.com/topic/63846-input-validation/#findComment-318245 Share on other sites More sharing options...
dbo Posted August 8, 2007 Author Share Posted August 8, 2007 *bump* would really like to get some more opinions on this. And what I'd like even more is to hear how other tackle the same problem... besides manually writing all the validation rules each time. Quote Link to comment https://forums.phpfreaks.com/topic/63846-input-validation/#findComment-318419 Share on other sites More sharing options...
Guardian-Mage Posted August 8, 2007 Share Posted August 8, 2007 If it cuts down your workload, go for it, if you are doing this for money, it is more profitable if you finish it faster, but then again, that depends on how you charge.... Quote Link to comment https://forums.phpfreaks.com/topic/63846-input-validation/#findComment-318428 Share on other sites More sharing options...
dbo Posted August 8, 2007 Author Share Posted August 8, 2007 I bill hourly so it's actually less money on a per project basis... but this is also a small part of a much larger attempt at creating a rapid application development framework that works for me. The goal is to cut down projects that take 3-4 weeks to complete into a handful of days and really pound through more projects and/or work on more projects concurrently. The result is a consistent platform to do maintenance and more elegant, easy to read code. I'd venture to say that I spend upwards of 70-90% of development time validating input and doing error checking. Quote Link to comment https://forums.phpfreaks.com/topic/63846-input-validation/#findComment-318455 Share on other sites More sharing options...
dbo Posted August 8, 2007 Author Share Posted August 8, 2007 *bump* Quote Link to comment https://forums.phpfreaks.com/topic/63846-input-validation/#findComment-318522 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.