Is this a Reasonable Validation Strategy?

Is it okay to put some custom validation methods in AppModel and call those from my app's Models? I want phone number validation to work the same for all phone numbers on my site and I want that validation rule to be in one place only. Is there a better way to do this?


This is absolutely reasonable and, really, the best way to do it.

If there are validation methods that are very specific to a certain model, I would just place those methods in the pertinent Model class, rather than AppModel. But since phone number validation is something that will be used by several models, AppModel is the perfect place for it. Now it's in one place and available in all your models.

Need Your Help

How do I define a function within a function in Clojure and reference that function?


I wrote a function to compute the symmetric difference of two sets (one of the problems on the 4clojure site). The function passed the unit tests, but it's not as clean as I would like, given that I