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
|
The .Net Framework RequiredAttribute accepts 0 for numeric types, is there a reason for the deviation with the ValidatePresenceAttribute? I have a case where we have a non nullable Decimal that can have 0 as a valid value; We have multiple options for dealing with this, but none of them are elegant. If there is a good reason for the deviation, would it be possible to introduce an AllowDefaultValues property that would be overrideable on the property or context level? If no change is possible, what is the recommended workaround to this issue; Set the field to NOT NULL in the database, remove ValidatePresence from the Property, and hand code the client side required field validators and manually validate null values posted to the Action to avoid ugly database error messages? Thanks for all of your help and support; you have, by far, the best ORM on the market. |
|
|
The reason for the difference in behaviour to [Required] is that LightSpeed pre-dates .NET validation attributes so we defined out own behaviour at the time we introduced validation concerns. What would be your "not present" value in the case of a non nullable decimal? We define this as the default value for the type which for a decimal is 0 so to that end if you have a custom rule around how to define the value being set which allows 0 but defines another magic value to indicate it not being assigned a value then you currently would need to implement this using custom validation.
|
|
|
There is no value to represent not defined, It's a fund management solution, so technically any number, positive or negative, is valid. Are there any plans to standardize the validation rules with the ones provided in .Net, maybe version 6? |
|