in reply to Data checking configuration files

I typically ignore checking config file contents when it is first loaded. Instead I get the functions using those settings to validate the data.

This way, if I choose to switch the input origin for the function (such as from config file to user input through a website), I know the input is still being validated before being consumed, without having to rebuild the cart, so to speak.

I don't think your way is wrong at all, just different :)

EDIT: In addition to the above, moving data validation into the consuming function makes the function complete within itself, which allows for greater code-reuse (if you're that way inclined).

Replies are listed 'Best First'.
Re^2: Data checking configuration files
by BillKSmith (Monsignor) on Sep 17, 2015 at 20:03 UTC
    I assume that your comments do not apply to validation issues related to the file itself, such as the files existence and syntax. Errors of this type should not propagate into using functions.
    Bill

      Of course not :)

      Whatever is loading the config file is responsible for validating its own inputs (in this case the file), exactly the same way as other functions consuming the various config values are responsible for validating them.