MVC Question: Should I put form validation rules in the controller or model?

前端 未结 9 1616
野性不改
野性不改 2020-12-12 14:41

On one hand form validation could be seen as part of the application logic and therefore belonging in the model.

On the other hand, it deals directly with the input

9条回答
  •  悲&欢浪女
    2020-12-12 15:39

    Validation is Model's issue. Only model knows how your data should look like. You describe your data fields in model, so you should describe validation rules for this fields in the same place.

    It seems to be obvious for me, but I'd gladly listen to opponents.

提交回复
热议问题