views:

47

answers:

1

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?

+2  A: 

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.

webbiedave