CodeIgniter Forums
2 ways of defining own rules in validation? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: 2 ways of defining own rules in validation? (/thread-29678.html)



2 ways of defining own rules in validation? - El Forum - 04-17-2010

[eluser]ajsie[/eluser]
according to this article:

http://www.phpandstuff.com/articles/codeigniter-doctrine-scratch-day-3-user-signup-form

it seems to be 2 ways of defining an own validation rule:

function[field]

and

callback_function

what's the difference and when should you use which one?


2 ways of defining own rules in validation? - El Forum - 04-17-2010

[eluser]dejitaru[/eluser]
The first method using a callback, is a function on the controller itself and the second one is extending the form_validation library. I don't know if there is a rule on using one or another. If I use only 1 specific validation rule on one controller, I use a callback but if I have a rule that many controllers use, I extend the library.