Loading…

How to create a validation object in FuelPHP?

1. Create an object.

2. Instantiate it, $val = Validation::forge('my_validation');

3. Start adding fields to it, $val = Validation::forge('my_validation');

4. Add username to it, $val->add('username', 'Your username')->add_rule;

5. Add column for password, $val->add('password', 'Your password')

     ->add_rule('required')

     ->add_rule('min_length', 3)

     ->add_rule('max_length', 10);

(The digits are as per the requirements)

6. Add the next field, the gender field- $val->add('gender', 'Your gender')-

     >add_rule('required')

    ->add_rule('match_collection', array('M', 'F'));

If any other validations are to be given, then give them using add_rule() method.

   Or

Forge ( ) method is used for creating a validating objects, such as $val= Validation:: forge( );

Suggest An Answer

No suggestions avaliable!

Latest post from FuelPHP Interview Questions

Ask Question