Click here to Skip to main content
15,885,980 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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"&gt;
      <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" &gt;          </validator></property>
The DAL Class DBTemp.cs mapped with LiquidTemperature Table in database contains a property as below:-
public Nullable &lt;double&gt; 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
Posted
Updated 18-Jul-11 18:59pm
v15
Comments
Tarun.K.S 17-Jul-11 14:52pm    
Damn it! It's not displaying the class.
Prachi, can you please post your question again, sorry for the inconvenience.
Something went horribly wrong while improving question, its just not displaying the class.
prachi sahai 19-Jul-11 0:03am    
sure I will
[no name] 19-Jul-11 0:31am    
Edited for Easy Readability and corrected the spelling.
[no name] 19-Jul-11 1:00am    
Edited for Code Block.
prachi sahai 20-Jul-11 5:09am    
Please help Community.. I am not through yet.. :(

1 solution

How large is this application? It's not unusual to find that trimming away prism and the Enterprise Library 5, reveals a much more manageable solution. Many solution becomes unnecessarily cluttered when built using those frameworks.

If you are working on a multi megabyte solution, and that excludes generated code, they may have a place - otherwise they are often just a waste of time and effort.

Anyway, tried a regex looking similar to this:
^[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?$


Best regards
Espen Harlinn
 
Share this answer
 
Comments
[no name] 19-Jul-11 0:32am    
Good Call.My 5.
prachi sahai 19-Jul-11 0:52am    
Thanks Espen but I am afraid it did not work. I have updated my question, so this is what i am exactly doing.Let me know if you need more inputs. Many Thanks :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900