Validating date fields in OCL

How to validate dates in OCL expressions.

Bold allows the model to specify a list of constraints in OCL (Object Constraint Language). The problem that I encountered was that OCL didn't understand a simple expression such as "startDate <= endDate" which is what I am used to doing in Delphi.

The solution is to cast the date as a "float" value. The following expression works perfectly.

startDate.DateTimeAsFloat <= endDate.DateTimeAsFloat

Information provided by Eric Holton on the Bold news groups, thanks Eric!.


Share this article!

Follow us!

Find more helpful articles: