SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Threaded View

  1. #1
    SitePoint Addict
    Join Date
    Sep 2004
    0 Post(s)
    0 Thread(s)

    I need some suggestions please ....

    hi ...

    An application I'm working on uses a ini file to store configuration variables. The client wants a web interface to add or modify the variables in the ini files. So basically I have to map the ini variables to a html form.


    somevar = somevalue
    someothervar = someothervalue

    would translate into

    <input type="text" name="somevar" value="somevalue" />
    <input type="text" name="someothervar" value="someothervalue" />
    <input type="submit" value="Save" />

    So far so good. The ini variables need to be validated. The solution I have right now for validation uses the Specification pattern for that. Something like this:

    PHP Code:
    $v =& new Validator();
    $v->addRule( new RegexpMatchRule'somevar''#^[a-zA-Z0-9]{3,24}$#''The %s variable must contain alphanumeric characters only and must be between 3 and 24 characters in length' ) );
    $v->addRule( new InListRule'someotherval'range010 ), 'The %s field must be an integer between 0 and 10' ) );
    if ( !
    $v->isValid$data ) ) {
        foreach ( 
    $v->getErrors() as $error ) {
    $error '<br />';

    The problem is that the client, when adding new variables to the ini file, wants to be able to specify the validation rules from the web interface ... so i have to save those rules somewhere (like an xml file or something) and when saving (from the web interface) parse the xml file and create the code above dynamically.

    My question is: how? (please consider that some of the validation rules can be ( and are ) more complex than the ones in the example (like
    PHP Code:
    $v->addRule( new AndRule( new RegexpMatchRule, new OrRule( new InListRule(), new CsvStringRule() ) ) ); 
    and that i also need to pass parameters to those rules ).

    I did a search on this forum but nothing useful came up so ... please help.

    Last edited by acid24ro; Jul 23, 2007 at 05:41.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts