.NET Framework 4.5.2+
.NET Framework 4.5.2+
.NET Standard 2.0+
.NET Core 3.0+

RuleRegularExpressionAttribute Class

Defines a validation rule that demands the target property match a specified pattern.

Namespace: DevExpress.Persistent.Validation

Assembly: DevExpress.Persistent.Base.v19.2.dll


[AttributeUsage(AttributeTargets.Property, AllowMultiple = true)]
public class RuleRegularExpressionAttribute :
<AttributeUsage(AttributeTargets.Property, AllowMultiple:=True)>
Public Class RuleRegularExpressionAttribute
    Inherits RuleBaseAttribute
    Implements IRuleRegularExpressionProperties,


Apply this attribute to a business class string property to define a validation rule that will check whether this property's value matches a specified regular expression. Use the pattern parameter to specify the regular expression that the property must match. In addition, use the common parameters that are inherited from the RuleBaseAttribute class.

private string email;
public string Email {
   get { return email; }
   set { SetPropertyValue(nameof(Email), ref email, value); }

The rule generated by the RuleRegularExpressionAttribute 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 RuleRegularExpression and other validation attributes in the Validation section of the FeatureCenter demo. This demo is located in the %PUBLIC%\Documents\DevExpress Demos 19.2\Components\eXpressApp Framework\FeatureCenter folder, by default.

See Also