Hi All,
I am working on MVVM pattern, using prism and Enterprise Library 5 validation block.
I have a View-ViewModel and a Data Access Layer(DAL) containing the class files with business entities of database table fields.
The TextBox in View mapped with Temperature property in ViewModel of Nullable "Double Type", while the View Model property is inturn mapped to DAL's Temperature property again of Nullable "Double Type".
The problem is I have to perform factory validation in ViewModel using the Ruleset from validation.config file with RegEx validator for checking "if the Temperature field is +ve double value", but I am afraid its not working.
The validation.config is as below:-
<type name="ViewModels.ViewModel">
assemblyName="Assemblyname, Version=1.0.0.0, Culture=neutral, PublicKeyToken=673ed9739f7ac7b7">
<ruleset name="RulesetName">
<properties> <property name="Temperature">
<validator type="Microsoft.Practices.EnterpriseLibrary.Validation.Validators.RegexValidator, Microsoft.Practices.EnterpriseLibrary.Validation, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
pattern="^[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?$" options="IgnoreCase" messageTemplate="Number should be positive value"
name="Regular Expression Validator" > </validator></property>
The DAL Class DBTemp.cs mapped with LiquidTemperature Table in database contains a property as below:-
public Nullable <double> Temperature
{
get { return Temp; }
set { Temp = value; OnPropertyChanged("Temperature"); }
}
The View Model Class contains a property as below:-
private DAL.LiquidTemperature _lqTemp;
public Nullable <double> Temperature
{
get { return _lqTemp.Temp; }
set { _lqTemp.Temp = value; RaisePropertyChanged("Temperature"); }
}
The View Contains below text:-
<textbox grid.column="1" maxlength="4" name="txtTemparature">
<textbox.text>
<binding path="Temparature" mode="TwoWay" updatesourcetrigger="PropertyChanged" validatesonexceptions="True" notifyonvalidationerror="True"> <binding.validationrules>
<vab:validatorrule rulesetname="RulesetName" sourcetype="{x:Type vm:ViewModelName}" validationstep="UpdatedValue" sourcepropertyname="Temparature" validationspecificationsource="Configuration" xmlns:vab="#unknown"> <binding.validationrules> </binding.validationrules></vab:validatorrule></binding.validationrules></binding>
</textbox.text>
</textbox>
Please help me.
Thanks in Advance