best way to add validation functions - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: best way to add validation functions (/showthread.php?tid=9273) |
best way to add validation functions - El Forum - 06-19-2008 [eluser]skattabrain[/eluser] hello, i've been trying to get my validation callbacks into some sort of single file so i can reuse the fucntions within this project as well as others. i've been adding these validation functions to a helper file, but things don't seem to work right. is there a better way than to add these fucntions in a helper? should i extend the validation class instead? i haven't extended ci in anyway yet ... trying to get the most out of a vanilla install for easy upgrading etc ... best way to add validation functions - El Forum - 06-19-2008 [eluser]ontguy[/eluser] I think extending the validation class is the best way to centralize callbacks: So I could have a username_duplicate_check callback function included in MY_Validation.php, then use it in the validation rules: Code: $rules['username'] = 'trim|required|username_duplicate_check'; I have been giving some thought about where to centralize rules for fields used in multiple controllers; I think a config file maybe the place to do it or maybe even putting it MY_Validation and overriding it if needed. |