G
Guest
I would like a particular business object to ask for validation when a
property is set to a specific value. In this case, I have a TimeStart
property and a TimeEnd property. When creating a new object, the default for
these properties is Now. However, saving the data with both values set to now
would be highly unusual, so I'd want the class to ask for verification. I
think this rule should be maintained by the class and not the UI (a windows
form).
One thought I had is to expose a boolean property called ZeroTimeAllowed.
The default would be False. If the rule found that ZeroTimeAllowed is false
and the time properties are the same, I would throw an exception. The UI
could then show a messagebox and then change the ZeroTimeAllowed to True if
the response is Yes.
I'm not crazy about this idea, because there would be nothing stopping the
UI developer (in this case, myself) from always setting ZeroTimeAllowed to
True.
Any advice would be helpful.
Thanks,
Barry
property is set to a specific value. In this case, I have a TimeStart
property and a TimeEnd property. When creating a new object, the default for
these properties is Now. However, saving the data with both values set to now
would be highly unusual, so I'd want the class to ask for verification. I
think this rule should be maintained by the class and not the UI (a windows
form).
One thought I had is to expose a boolean property called ZeroTimeAllowed.
The default would be False. If the rule found that ZeroTimeAllowed is false
and the time properties are the same, I would throw an exception. The UI
could then show a messagebox and then change the ZeroTimeAllowed to True if
the response is Yes.
I'm not crazy about this idea, because there would be nothing stopping the
UI developer (in this case, myself) from always setting ZeroTimeAllowed to
True.
Any advice would be helpful.
Thanks,
Barry