CodeIgniter Forums
Make Validation Config to Extend BaseConfig - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Feature Requests (https://forum.codeigniter.com/forumdisplay.php?fid=29)
+--- Thread: Make Validation Config to Extend BaseConfig (/showthread.php?tid=81180)



Make Validation Config to Extend BaseConfig - sadiqsalau - 02-01-2022

I am creating a project which includes so may plug and play modules, I use Registrar to Extend Filters and Some other Configs, But the Validation Config doesn't extend the BaseConfig so I can't add rules to it except I modify it directly. 
It would be nice to place all rules into a $rules property so that different modules can add theirs to it.
e.g
PHP Code:
<?php

namespace Config;

use 
CodeIgniter\Config\BaseConfig;
use 
CodeIgniter\Validation\CreditCardRules;
use 
CodeIgniter\Validation\FileRules;
use 
CodeIgniter\Validation\FormatRules;
use 
CodeIgniter\Validation\Rules;

class 
Validation extends BaseConfig
{
    //--------------------------------------------------------------------
    // Setup
    //--------------------------------------------------------------------

    /**
    * Stores the classes that contain the
    * rules that are available.
    *
    * @var string[]
    */
    public $ruleSets = [
        Rules::class,
        FormatRules::class,
        FileRules::class,
        CreditCardRules::class,
    ];

    /**
    * Specifies the views that are used to display the
    * errors.
    *
    * @var array<string, string>
    */
    public $templates = [
        'list'  => 'CodeIgniter\Validation\Views\list',
        'single' => 'CodeIgniter\Validation\Views\single',
    ];

    //--------------------------------------------------------------------
    // Rules
    //--------------------------------------------------------------------
    public $rules = [
        'login'=>[
            //
        ]
    ];




RE: Make Validation Config to Extend BaseConfig - MGatner - 02-06-2022

I wasn’t even aware! I’m not sure why this isn’t the case, but if you send over a Pull Request it should stir up any relevant discussion on the topic.


RE: Make Validation Config to Extend BaseConfig - datamweb - 02-18-2022

Hi,I also had this problem. I have already created a topic in this link, but no one has sent a reply.


RE: Make Validation Config to Extend BaseConfig - kenjis - 03-08-2022

Now Registrars can add rules.
https://github.com/codeigniter4/CodeIgniter4/pull/5789


RE: Make Validation Config to Extend BaseConfig - ipmeel - 10-14-2022

(03-08-2022, 11:18 PM)kenjis Wrote: Now Registrars can add rules.
https://github.com/codeigniter4/CodeIgniter4/pull/5789

Hi,
I am still unable to figure out to use Registrar to extend Validation in modules (without making change to app/Config/Validation.php). May I ask if anyone can share a sample script?


RE: Make Validation Config to Extend BaseConfig - kenjis - 10-14-2022

See https://github.com/codeigniter4/shield/blob/f4cdfb672b600a032a6f0bfc0b7735411bee0cae/src/Config/Registrar.php#L31
and https://codeigniter4.github.io/CodeIgniter4/general/configuration.html#registrars


RE: Make Validation Config to Extend BaseConfig - ipmeel - 10-14-2022

(10-14-2022, 05:06 AM)kenjis Wrote: See https://github.com/codeigniter4/shield/blob/f4cdfb672b600a032a6f0bfc0b7735411bee0cae/src/Config/Registrar.php#L31
and https://codeigniter4.github.io/CodeIgniter4/general/configuration.html#registrars

Hi,
Thank you very much for a prompt solution.
The issue has been solved (as per your guide).
Regards.


RE: Make Validation Config to Extend BaseConfig - sadiqsalau - 10-14-2022

It works now  Smile . Thanks