Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Codeigniter. Validate PUT data

I am developing an API using Phils RestServer and I need to validate incoming PUT data. It works fine with incoming POST data but not PUT.

How can I validate data that are sent via PUT?

Thankful for all input!

like image 663
Jonathan Clark Avatar asked Dec 27 '22 15:12

Jonathan Clark


2 Answers

Nope! Doesn't work. What you CAN do is hack it, so:

$_POST['foo'] = $this->put('foo');

Allowing the CodeIgniter Form Validation class to validate things other than POST is on the todo list (for exactly this reason).

like image 140
Phil Sturgeon Avatar answered Jan 14 '23 22:01

Phil Sturgeon


Here is my solution. I am using set_data() function from form validation library:

$set_data = array(
        'username'  => $this->put('username'),
        'email'     => $this->put('email'),
        'zipcode'   => $this->put('zipcode'),
        'telephone' => $this->put('telephone'),
        'password'  => $this->put('password'),
    );

    $this->form_validation->set_data($set_data);
    $this->form_validation->set_rules($this->Register_model->rules_register);
like image 37
Florin Avatar answered Jan 15 '23 00:01

Florin