Enterprise Library ObjectValidator


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 1 of 1

Thread: Enterprise Library ObjectValidator

  1. #1
    Join Date
    Dec 2007
    Posts
    1

    Enterprise Library ObjectValidator

    I'm trying to validate user input using the Enterprise Library provided by Microsoft.

    I've run into a problem when I'm trying to validate a sub class. i.e. I'm validating a Theme class which has a property called CoverFrameColor, this is of type MyColor. MyColor has 3 properties Red, Green and Blue. I need to validate that each property is within the range 0 - 255.

    I'm doing this through app.config as well. The problem comes because I'm using the Tag property of the validator to store the control to display and update with the error message on the form.

    When I use the ObjectValidator to validate CoverFrameColor, it validates correctly the problem is that I can seem to get the Tag value of the ObjectValidator, I can only get the tag values of the individual rangevalidators on the Red, Green and Blue properties.

    Has anybody got any ideas on how I can validate these sub class properties but retain the Tag value from the FrameColor validator?

    Here's the app.config.
    Code:
    <type defaultRuleset="ThemeDefinitionDefaultRuleSet" assemblyName="ThemeDefinitionTool, Version=1.0.2900.27879, Culture=neutral, PublicKeyToken=null"
          name="ThemeDefinitionTool.ThemeDefinition">
          <ruleset name="ThemeDefinitionDefaultRuleSet">
            <properties>
              <property name="CoverFrameColor">
                <validator targetRuleset="MyColorDefaultRuleSet" type="Microsoft.Practices.EnterpriseLibrary.Validation.Validators.ObjectValidator, Microsoft.Practices.EnterpriseLibrary.Validation, Version=3.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
                  name="Object Validator" />
              </property>
     </type>
     <type defaultRuleset="MyColorDefaultRuleSet" assemblyName="ThemeDefinitionTool, Version=1.0.2902.30020, Culture=neutral, PublicKeyToken=null"
          name="ThemeDefinitionTool.MyColor">
          <ruleset name="MyColorDefaultRuleSet">
            <properties>
              <property name="Red">
                <validator lowerBound="0" lowerBoundType="Inclusive" upperBound="255"
                  upperBoundType="Inclusive" negated="false" messageTemplate="Must be between 0 - 255"
                  messageTemplateResourceName="" messageTemplateResourceType=""
                  tag="" type="Microsoft.Practices.EnterpriseLibrary.Validation.Validators.RangeValidator, Microsoft.Practices.EnterpriseLibrary.Validation, Version=3.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
                  name="Range Validator" />
              </property>
              <property name="Green">
                <validator lowerBound="0" lowerBoundType="Inclusive" upperBound="255"
                  upperBoundType="Inclusive" negated="false" messageTemplate="Must be between 0 - 255"
                  messageTemplateResourceName="" messageTemplateResourceType=""
                  tag="" type="Microsoft.Practices.EnterpriseLibrary.Validation.Validators.RangeValidator, Microsoft.Practices.EnterpriseLibrary.Validation, Version=3.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
                  name="Range Validator" />
              </property>
              <property name="Blue">
                <validator lowerBound="0" lowerBoundType="Inclusive" upperBound="255"
                  upperBoundType="Inclusive" negated="false" messageTemplate="Must be between 0 - 255"
                  messageTemplateResourceName="" messageTemplateResourceType=""
                  tag="" type="Microsoft.Practices.EnterpriseLibrary.Validation.Validators.RangeValidator, Microsoft.Practices.EnterpriseLibrary.Validation, Version=3.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
                  name="Range Validator" />
              </property>
            </properties>
          </ruleset>
        </type>
    Thanks
    Last edited by Hack; 12-13-2007 at 07:36 AM. Reason: Added Code Tags

Similar Threads

  1. Replies: 2
    Last Post: 06-12-2007, 01:56 PM
  2. Working with Crystal Report Ver 10
    By AM003295 in forum VB Classic
    Replies: 4
    Last Post: 08-12-2005, 10:13 PM
  3. ANN: The XtraGrid Suite & XtraEditors Library - 100% Native .NET Components
    By Developer Express in forum dotnet.announcements
    Replies: 0
    Last Post: 10-06-2001, 03:43 PM
  4. Replies: 0
    Last Post: 10-06-2001, 03:43 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center