Im facing a bit of an issue when trying to validate a decimal property on domain object which is bound to a textbox on the view through the viewmodel.
I am using NHibernate to decorate my property on the domain object as below.
private decimal _refurbishmentFee;
[Min(Value=0), NotNull]
public decimal RefurbishmentFee
{
get { return _refurbishmentFee; }
set
{
if (_refurbishmentFee == value) return;
_refurbishmentFee = value;
OnPropertyChanged("RefurbishmentFee");
}
}
The validation works fine if I put in a number less than 0, however if I put in alpha characters or a space then nothing happens, the application doesn’t even fall into the setter.
Any help?
Thanks
Faisal
Yes I am using ValidatesOnDataErrors in the XAML. Fortunately one of my colleagues resolved this issue last night so I thought I should put it on here in case someone else is in the same position.
To get the validation to occur in all cases you need to add ValidatesOnExceptions=”True” as well as ValidatesOnDataErrors=”True” in the XAML.
Then on the domain object use standard NHibernate validation decorators.
Thanks,
Faisal