Validation on double field

Oct 12, 2012 at 9:21 PM

Hi, tried validation on a property with double return type (Need to enforce Amount to be not null)

public double Amount
get{return _amount;

Validator.AddRequiredRule(() => Amount, "Amount is required");

Got following error "value '' could not be converted" when I leave Amount field blank. Could you suggest the workaround?



Oct 22, 2013 at 8:56 AM

same issue here. i use version 1.0.1
hope there will be a new release soon.

thanks & regards
Oct 24, 2013 at 8:28 AM
As I mentioned here, the "Validator.AddRequiredRule" for a "double" field will never work because the field value cannot be NULL or empty string. The message that you are seeing is coming from the binding system, not from the validation framework, and it tells you that it cannot convert an empty string to a "double" value.
Oct 24, 2013 at 2:28 PM
Makes sense :)
thank you !