This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Hi - I have a column defined as follows: [ValidatePresence] private double _min; |
|
|
Hello Dave, This is expected behaviour, and I'm surprised it ever passed validation. As you note, a default value is considered "not present," and since 0.0 is the default value for double, a value of 0.0 is considered "not present." The reason for this is that the _min field always has a value -- this is enforced by the .NET type system -- the semantics of presence validation are therefore more 'someone has set the value (away from the default).' If you are willing to accept 0.0 for _min, then you should remove the ValidatePresence attribute, because there is effectively no requirement to set a value for _min -- the default will do. Alternatively, you could do something like setting _min = Double.NaN in the constructor, and using a custom validation to check that the value is no longer NaN. |
|
|
Thanks, Ivan. I don't know why it was working, but I can see where .NET has to have something there. The database is happy setting it to DBNull, but that's a concept not natively supported by .NET...
|
|