开发者

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?开发者_如何学Python 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜