jamierumbelow/codeigniter-base-model — pull request #116 by jurassic-c (2013-04-12 20:55:22+00:00)
Title: Validation Callbacks

Validation Callbacks
------------------------------

I added 4 callbacks for before and after validation of the model, on create and on update. I find these useful in particular for handling the issue of validating unique columns. I can use these callbacks to insert and remove the `is_unique` rule as necessary. For reference, this modified Form_Validation class works well for validating unique columns on update: http://ellislab.com/forums/viewthread/192334/

There's probably a better way of solving this issue, but either way, these callbacks could still be useful.

Has Many Ordering
-----------------------------

I added an option `order_by` to the `$has_many` array. This is useful for loading up your related objects in a more useful order than their id.

Possible bugfix for MY_Model::get()
-----------------------------------------------------

I found that when I tried to get a non-existent record from the database with it's related child objects, PHP would throw an error. Now in that situation, when the record doesn't exist, an empty array is returned.

Mock Form Validation Class
------------------------------------------
I added a mock form validation class so all of the validation related tests would pass. I don't know if this solution is what works best or if I've set it up appropriately, as I haven't looked too deeply into your testing setup.