How to handle db constraint violations in the user interface?

后端 未结 6 1416
暖寄归人
暖寄归人 2021-02-05 15:37

We implement the majority of our business rules in the database, using stored procs.

I can never decide how best to pass data constraint violation errors from the databa

6条回答
  •  隐瞒了意图╮
    2021-02-05 16:35

    I've seen lots of Ajax based applications doing a real-time check on fields such as username (to see if it already exists) as soon as the user leaves the edit box. It seems to me a better approach than leaving to the database to raise an exception based on a db constraint - it is more proactive since you have a real process: get the value, check to see if it is valid, show error if not, allow to continue if no error. So it seems option 2 is a good one.

提交回复
热议问题