Welcome Guest, Not a member yet? Register   Sign In
Form Validation Rulesets (alternative syntax proposal)
#2

Hey,

I think this is a great idea! I've come up with a slightly different form_validation.php config that removes some of the redundancy as well:

Code:
/*
|--------------------------------------------------------------------------
| First Name Validation
|--------------------------------------------------------------------------
|
| Standard validation for first name input
|
*/
$first_name_validation = array(
    'field'    => 'first_name',
    'label'    => 'First Name',
    'rules'    => 'trim|required|max_length[15]'
);
/*
|--------------------------------------------------------------------------
| Last Name Validation
|--------------------------------------------------------------------------
|
| Standard validation for last name input
|
*/
$last_name_validation = array(
    'field'    => 'last_name',
    'label'    => 'Last Name',
    'rules'    => 'trim|required|max_length[40]'
);

Then in the config array:

[code]/*
|--------------------------------------------------------------------------
| Validation Rule Sets
|--------------------------------------------------------------------------
|
| Sets of rules used throughout website
|
*/
$config = array(
'contact' => array(
$first_name_validation,
$last_name_validation,
),
'register' => array(
$first_name_validation,
$last_name_validation,
),
);

Cheers!
Reply


Messages In This Thread
RE: Form Validation Rulesets (alternative syntax proposal) - by versalle88 - 02-03-2015, 12:24 PM



Theme © iAndrew 2016 - Forum software by © MyBB