Log In
Home
Support
Demos
Documentation
Blogs
Training
Webinars
[Expand]General Information
[Expand]WinForms Controls
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Document Server
[Expand]Reporting
[Expand]Report Server
[Expand]Dashboard
[Collapse]eXpressApp Framework
 [Expand]Fundamentals
 [Expand]Getting Started
 [Expand]Concepts
 [Expand]Design-Time Features
 [Expand]Functional Testing
 [Expand]Deployment
 [Expand]Task-Based Help
 [Expand]Frequently Asked Questions
 [Collapse]API Reference
  [Expand]DevExpress.EasyTest.Framework
  [Expand]DevExpress.ExpressApp
  [Expand]DevExpress.ExpressApp.Actions
  [Expand]DevExpress.ExpressApp.AuditTrail
  [Expand]DevExpress.ExpressApp.Chart
  [Expand]DevExpress.ExpressApp.Chart.Web
  [Expand]DevExpress.ExpressApp.Chart.Win
  [Expand]DevExpress.ExpressApp.CloneObject
  [Expand]DevExpress.ExpressApp.ConditionalAppearance
  [Expand]DevExpress.ExpressApp.Dashboards
  [Expand]DevExpress.ExpressApp.Dashboards.Web
  [Expand]DevExpress.ExpressApp.Dashboards.Win
  [Expand]DevExpress.ExpressApp.Data
  [Expand]DevExpress.ExpressApp.DC
  [Expand]DevExpress.ExpressApp.DC.ClassGeneration
  [Expand]DevExpress.ExpressApp.Editors
  [Expand]DevExpress.ExpressApp.EF
  [Expand]DevExpress.ExpressApp.EF.Utils
  [Expand]DevExpress.ExpressApp.FileAttachments.Web
  [Expand]DevExpress.ExpressApp.FileAttachments.Win
  [Expand]DevExpress.ExpressApp.Filtering
  [Expand]DevExpress.ExpressApp.HtmlPropertyEditor.Web
  [Expand]DevExpress.ExpressApp.HtmlPropertyEditor.Win
  [Expand]DevExpress.ExpressApp.Kpi
  [Expand]DevExpress.ExpressApp.Layout
  [Expand]DevExpress.ExpressApp.Maps.Mobile
  [Expand]DevExpress.ExpressApp.Maps.Mobile.Editors
  [Expand]DevExpress.ExpressApp.Maps.Web
  [Expand]DevExpress.ExpressApp.Maps.Web.Helpers
  [Expand]DevExpress.ExpressApp.MiddleTier
  [Expand]DevExpress.ExpressApp.Mobile
  [Expand]DevExpress.ExpressApp.Mobile.Editors
  [Expand]DevExpress.ExpressApp.Mobile.MobileModel
  [Expand]DevExpress.ExpressApp.Mobile.SystemModule
  [Expand]DevExpress.ExpressApp.Model
  [Expand]DevExpress.ExpressApp.Model.Core
  [Expand]DevExpress.ExpressApp.Model.NodeGenerators
  [Expand]DevExpress.ExpressApp.ModelEditor
  [Expand]DevExpress.ExpressApp.Notifications
  [Expand]DevExpress.ExpressApp.Notifications.Web
  [Expand]DevExpress.ExpressApp.Notifications.Win
  [Expand]DevExpress.ExpressApp.PivotChart
  [Expand]DevExpress.ExpressApp.PivotChart.Web
  [Expand]DevExpress.ExpressApp.PivotChart.Win
  [Expand]DevExpress.ExpressApp.PivotGrid
  [Expand]DevExpress.ExpressApp.PivotGrid.Web
  [Expand]DevExpress.ExpressApp.PivotGrid.Win
  [Expand]DevExpress.ExpressApp.Reports
  [Expand]DevExpress.ExpressApp.Reports.Web
  [Expand]DevExpress.ExpressApp.Reports.Win
  [Expand]DevExpress.ExpressApp.ReportsV2
  [Expand]DevExpress.ExpressApp.ReportsV2.Web
  [Expand]DevExpress.ExpressApp.ReportsV2.Win
  [Expand]DevExpress.ExpressApp.Scheduler
  [Expand]DevExpress.ExpressApp.Scheduler.Web
  [Expand]DevExpress.ExpressApp.Scheduler.Win
  [Expand]DevExpress.ExpressApp.ScriptRecorder
  [Expand]DevExpress.ExpressApp.ScriptRecorder.Web
  [Expand]DevExpress.ExpressApp.ScriptRecorder.Win
  [Expand]DevExpress.ExpressApp.Security
  [Expand]DevExpress.ExpressApp.Security.Adapters
  [Expand]DevExpress.ExpressApp.Security.ClientServer.Wcf
  [Expand]DevExpress.ExpressApp.Security.EF.Adapters
  [Expand]DevExpress.ExpressApp.Security.Strategy
  [Expand]DevExpress.ExpressApp.Security.Xpo.Adapters
  [Expand]DevExpress.ExpressApp.StateMachine
  [Expand]DevExpress.ExpressApp.SystemModule
  [Expand]DevExpress.ExpressApp.Templates
  [Expand]DevExpress.ExpressApp.Templates.ActionContainers
  [Expand]DevExpress.ExpressApp.TreeListEditors
  [Expand]DevExpress.ExpressApp.TreeListEditors.Web
  [Expand]DevExpress.ExpressApp.TreeListEditors.Win
  [Expand]DevExpress.ExpressApp.Updating
  [Expand]DevExpress.ExpressApp.Utils
  [Expand]DevExpress.ExpressApp.Validation
  [Expand]DevExpress.ExpressApp.Validation.Web
  [Expand]DevExpress.ExpressApp.Validation.Win
  [Expand]DevExpress.ExpressApp.ViewVariantsModule
  [Expand]DevExpress.ExpressApp.Web
  [Expand]DevExpress.ExpressApp.Web.Controls
  [Expand]DevExpress.ExpressApp.Web.Editors
  [Expand]DevExpress.ExpressApp.Web.Editors.ASPx
  [Expand]DevExpress.ExpressApp.Web.SystemModule
  [Expand]DevExpress.ExpressApp.Web.Templates
  [Expand]DevExpress.ExpressApp.Web.Utils
  [Expand]DevExpress.ExpressApp.Win
  [Expand]DevExpress.ExpressApp.Win.Core
  [Expand]DevExpress.ExpressApp.Win.Editors
  [Expand]DevExpress.ExpressApp.Win.Model
  [Expand]DevExpress.ExpressApp.Win.SystemModule
  [Expand]DevExpress.ExpressApp.Win.Templates
  [Expand]DevExpress.ExpressApp.Win.Templates.Navigation
  [Expand]DevExpress.ExpressApp.Workflow
  [Expand]DevExpress.ExpressApp.Workflow.Win
  [Expand]DevExpress.ExpressApp.Xpo
  [Expand]DevExpress.ExpressApp.Xpo.Utils
  [Expand]DevExpress.Persistent.Base
  [Expand]DevExpress.Persistent.Base.General
  [Expand]DevExpress.Persistent.Base.ReportsV2
  [Expand]DevExpress.Persistent.Base.Security
  [Expand]DevExpress.Persistent.BaseImpl
  [Expand]DevExpress.Persistent.BaseImpl.EF
  [Expand]DevExpress.Persistent.BaseImpl.EF.PermissionPolicy
  [Expand]DevExpress.Persistent.BaseImpl.PermissionPolicy
  [Collapse]DevExpress.Persistent.Validation
   [Expand]CodeRuleAttribute Class
   [Expand]ContextIdentifier Structure
   [Expand]ContextIdentifiers Structure
    CriteriaEvaluationBehavior Enumeration
   [Expand]CustomIsEmptyValueEventArgs Class
   [Expand]CustomNeedToValidateRuleEventArgs Class
   [Expand]CustomValidateRuleEventArgs Class
    DefaultContexts Enumeration
   [Expand]GenerateMessageTemplatesModelAttribute Class
   [Expand]IEmptyCheckable Interface
   [Expand]IModelValidationDefaultErrorMessageTemplates Interface
   [Expand]IRule Interface
   [Expand]IRuleBaseProperties Interface
   [Expand]IRuleCollectionPropertyProperties Interface
   [Expand]IRuleSource Interface
   [Expand]IRuleSupportsCollectionAggregatesProperties Interface
    ParametersMode Enumeration
   [Expand]RuleBase Class
   [Expand]RuleBaseAttribute Class
   [Expand]RuleBaseProperties Class
   [Expand]RuleCombinationOfPropertiesIsUniqueAttribute Class
   [Expand]RuleCombinationOfPropertiesIsUniqueProperties Class
   [Expand]RuleCriteriaAttribute Class
   [Expand]RuleCriteriaProperties Class
   [Expand]RuleFromBoolPropertyAttribute Class
   [Expand]RuleFromBoolPropertyProperties Class
   [Expand]RuleIsReferencedAttribute Class
   [Expand]RuleIsReferencedProperties Class
   [Expand]RuleObjectExistsAttribute Class
   [Expand]RuleObjectExistsProperties Class
   [Expand]RulePropertyValueProperties Class
   [Expand]RuleRangeAttribute Class
   [Expand]RuleRangeProperties Class
   [Expand]RuleRegularExpressionAttribute Class
   [Expand]RuleRegularExpressionProperties Class
   [Expand]RuleRequiredFieldAttribute Class
   [Expand]RuleRequiredFieldProperties Class
   [Expand]RuleSearchObjectProperties Class
   [Expand]RuleSet Class
   [Expand]RuleStringComparisonAttribute Class
   [Expand]RuleStringComparisonProperties Class
   [Expand]RuleUniqueValueAttribute Class
   [Expand]RuleUniqueValueProperties Class
   [Expand]RuleValidatedEventArgs Class
   [Expand]RuleValidationResult Class
   [Collapse]RuleValueComparisonAttribute Class
     RuleValueComparisonAttribute Members
    [Expand]RuleValueComparisonAttribute Constructor
    [Expand]RuleValueComparisonAttribute Properties
   [Expand]RuleValueComparisonProperties Class
    StringComparisonType Enumeration
   [Expand]ValidationCompletedEventArgs Class
   [Expand]ValidationException Class
    ValidationOutcome Enumeration
    ValidationResultType Enumeration
    ValidationState Enumeration
   [Expand]Validator Class
    ValueComparisonType Enumeration
[Expand]CodeRush
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation

RuleValueComparisonAttribute Class

Defines a validation rule that demands the target property's value satisfy a specified condition.

Namespace:DevExpress.Persistent.Validation
Assembly:DevExpress.Persistent.Base.v17.1.dll

Expanded Syntax

Expanded Remarks

Apply this attribute to a business class property to define a validation rule that will check whether this property's value satisfies a specified condition. Use the operatorType parameter to specify the operator type that must be used when comparing values. The available values of this parameter are the ValueComparisonType enumeration values. Here they are:

  • Equals
  • GreaterThan
  • GreaterThanOrEqual
  • LessThan
  • LessThanOrEqual
  • NotEquals

Use the rightOperand parameter to specify the value to be compared with the target property's value.

When applying this attribute, use common parameters that are inherited from the RuleBaseAttribute class, in addition to the specific parameters.

Note

The RuleValueComparisonAttribute can be applied to properties of value types. To compare other type properties, use RuleStringComparisonAttribute and RuleCriteriaAttribute.

The attribute constructor above expects a constant value as the rightOperand parameter. To refer to a property of the current object (or to compare with a calculated expression), set the mode parameter to ParametersMode.Expression using the following constructor.

The rule generated by the RuleValueComparisonAttribute will be loaded to the Application Model's IModelValidationRules node. So, you can customize this rule via the Model Editor. In addition, you can create new rules in the Model Editor as well. This is helpful when you need to add a rule to a property which is implemented in a base class provided by a third party library. For details, refer to the Implement Property Value Validation in the Application Model topic.

You can see examples of using the RuleValueComparison and other validation attributes in the Validation section of the FeatureCenter demo. This demo is located in the %PUBLIC%\Documents\DevExpress Demos 17.1\Components\eXpressApp Framework\FeatureCenter folder, by default.

Expanded Inheritance Hierarchy

System.Object
    System.Attribute
       RuleBaseAttribute
          RuleValueComparisonAttribute

Expanded See Also

How would you rate this topic?​​​​​​​