Custom attribute that, when added to a field, property or parameter, throws an ArgumentException if the target is assigned a value that does not match a given regular expression. Null strings are accepted and do not throw an exception.
Inheritance
Namespace: PostSharp.Patterns.Contracts
Assembly: PostSharp.Patterns.Common.dll
Syntax
public class RegularExpressionAttribute : LocationContractAttribute, ILocationLevelAspect, IAspect
Remarks
Error message is identified by RegularExpressionErrorMessage.
Error message can use additional argument
Constructors
Name | Description |
---|---|
RegularExpressionAttribute(string) | Initializes a new RegularExpressionAttribute. |
RegularExpressionAttribute(string, RegexOptions) | Initializes a new RegularExpressionAttribute and specify options. |
Methods
Name | Description |
---|---|
GetErrorMessage() | Gets unformatted error message as defined by the instance. |
GetErrorMessageArguments() | Gets values of additional arguments for error message associated with particular instance of LocationContractAttribute.
There arguments can be referenced from error message string by |
ValidateValueDynamic(object, string, LocationKind, LocationValidationContext) | Validates a weakly-typed (boxed) value, typically the value of a dependency property or an attached property. |