[英]date range validation groovy grails
I am new to groovy grails so any help would be appreciated. 我是groovy grails的新手,所以我们将不胜感激。 I am working on a grails application which tracks employee workplace history.
我正在研究一个grails应用程序,该应用程序可跟踪员工的工作场所历史。 One of the validation requirements is that the start date and end date duration for an employee should not overlap.
验证要求之一是员工的开始日期和结束日期持续时间不应重叠。 That means the startDate..endDate range should be unique among his employment dates for every employee.
这意味着startDate..endDate范围在每个雇员的受雇日期中应该是唯一的。 So my question is that how should I handle this validation ?
所以我的问题是我应该如何处理此验证? Should it be done in the static constraint block as a custom validator or it should be done in database level?
应该在静态约束块中作为自定义验证器完成它还是应该在数据库级别完成?
While your implementation of this is probably dependent on your specific needs, there is no absolutely correct answer on how you should do this. 虽然你的实现是可能取决于您的特定需求,对你应该怎么做这个没有绝对正确的答案。 There are good reasons for one or the other though:
但是,其中一个或另一个有充分的理由:
From my perspective, I'd implement the validator in the application only, then have a way for handling invalid data if it's loaded from elsewhere. 从我的角度来看,我只会在应用程序中实现验证器,然后有一种方法来处理无效数据(如果该数据是从其他位置加载的)。 If data validity is paramount, then I'd probably implement the validator in both places, being 100% sure that the logic matches!
如果数据有效性至关重要,那么我可能会在两个地方都实现验证器,请确保100%确保逻辑匹配!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.