Darren Duncan wrote:
Type constraints are supposed to be deterministic and not depend on variables (such as a mutable database) to determine whether they pass or not. Another example of misusing a type constraint is having a constraint that says "this datestamp is within 3 seconds of the current systemtime".
I should clarify this last comment. The datestamp example was assuming the type constraint would be actually checking the current system time, eg using time(), when run to test a value. On the other hand, that kind of constraint could be made valid if done in a different way. If you had another attribute in your object that is initialized to value of the current system time, and then your "within 3 seconds" constraint was then a dependent attribute constraint, saying the given timestamp must be within 3 seconds of the other attribute, then that is okay, because you are then testing deterministically, and any rerunning of the constraint in the future on the same object, where you haven't mutated the object, would pass later same as it passed the first time. -- Darren Duncan