• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Required Validation

#1
I was testing the required_without validation rule, then I observed it's not working as I thought it is/was supposed to. 

I was expecting the rule to return a required response if the field passed into the rule does not exit in the form or the field is empty, just like laravel does. 

Please do enlighten me.
Reply

#2
You're right, that's how it should work. If it doesn't currently, please post an issue with details and code examples.
Support Development  • Practical CodeIgniter 3  •
Myth:AuthVulcan - CLI Tools for CI4
Reply

#3
Hello, this doesn't work for me either, or I am doing something wrong. I checked the issues on it in Github and they're all closed...
       
PHP Code:
$validation = \Config\Services::validation();
$validation->setRules([
    'username' => ['label' => 'Login''rules' => 'required_without[phone,email]|max_length[30]'],
    'password' => ['label' => 'Pass''rules' => 'required|min_length[4]|max_length[30]'],
    'first_name' => ['label' => 'Name''rules' => 'max_length[30]'],
    'email' => ['label' => 'Your email''rules' => 'permit_empty|required_without[username,phone]|valid_email|max_length[60]'],
    'phone' => ['label' => 'Your phone''rules' => 'permit_empty|required_without[username,email]|alpha_numeric|max_length[25]']
]);
if(!empty(
$_POST['submit'])) {
    if($validation->withRequest($this->request)->run()) {
        echo 'success';
    }

Is something wrong here? I'm trying to force the user to write either username, email, or phone
You can see things I made with codeigniter here: itart.pro its not overly impressive as I have very little time to learn.
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.