Jump to content

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/63846-input-validation/
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/63846-input-validation/#findComment-318245
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/63846-input-validation/#findComment-318455
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.