CodeIgniter Forums
REST API Atribute Validation - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=11)
+--- Thread: REST API Atribute Validation (/showthread.php?tid=62785)



REST API Atribute Validation - TarikHuber - 08-26-2015

Hy,

I am creating a web page with API functionalites. For that I use this library: https://github.com/chriskacerguis/codeigniter-restserver

For now it works fine, but I am searching for a good and fast vay fro validating the call atributes. Someone suggested to me to use the form_validation for the validation and that also works but I can not get the error_message if the validation fails. It just returns a emty string. And the form_validation works only on the post calls. If I try to use it on a PUT call the validation fails.

Does someon know a good practice for validating atributes in REST_Controll-s?


RE: REST API Atribute Validation - mwhitney - 08-26-2015

To use data from a PUT call, pass the data to $this->form_validation->set_data($data).

Since you probably don't have much use for the form helper's form_error() function in a REST environment, you can use the form_validation library's error() method, which takes the same parameters as form_error().