After some tests, I realized that [PastConstraint] and [FutureConstraint] are working with local time. It is common for projects I have worked on to deal with dates in UTC on the backend side (service and database) and only convert to local time at the presentation layer (could be single or multiple local time display).

But then I found that it was easy enough to implement custom constraints and so I made 2 additional constraints [PastUtcConstraint] & [FutureUtcConstraint]. Very nice to be able to easily define new constraints :-)

I still have a problem with [FutureConstraint]. During the tests, it appeared that ALL defined entity validations are performed as soon as a single property is changed on a given entity. This is not problematic for time invariant validations (string length, number range, …) but it is problematic for [FutureContraint] because any change to an entity at a future time will eventually fail the validation on a [FutureConstraint] property that was set sometime in the past.

Then I thought that I could fix this using ContrainMode=OnSetValue, which I thought would evaluate the constraint ONLY when I set the corresponding DateTime property but this did not work as it seems the validation is still performed when I change other properties.

Is anyone aware of a trick I have not figured out yet?

Thanks, Patrick

asked Jan 16 '11 at 13:04

pcournoyer's gravatar image


edited Jan 24 '11 at 10:24

Dmitri%20Maximov's gravatar image

Dmitri Maximov

One Answer:

Hello Peter,

You are right, the property constraints are being checked whenever they have Mode property set to OnValidate or OnSetValue. We'll fix this shortly.

answered Jan 17 '11 at 07:18

Dmitri%20Maximov's gravatar image

Dmitri Maximov

The issue is fixed, updated binaries will be ready within several days.

(Jan 17 '11 at 09:23) Dmitri Maximov Dmitri%20Maximov's gravatar image

Thanks a lot for this quick fix!


(Jan 17 '11 at 10:13) pcournoyer pcournoyer's gravatar image

DataObjects.Net 4.3.7 & 4.4 beta 2 is released.

(Jan 29 '11 at 04:21) Dmitri Maximov Dmitri%20Maximov's gravatar image

Yes indeed, it works nicely now even with my custom UTC constraints. Thanks again.

(Feb 01 '11 at 20:51) pcournoyer pcournoyer's gravatar image
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!
toggle preview

powered by OSQA