Class StringLengthAttribute
Custom attribute that, when added to a field, property or parameter, throws an ArgumentException if the target is assigned a string of invalid length. Null strings are accepted and do not throw an exception.
Namespace: PostSharp.Patterns.Contracts
Assembly: PostSharp.Patterns.Common.dll
Syntax
[HasConstraint]
public sealed class StringLengthAttribute : LocationContractAttribute, ILocationLevelAspect, IAspect
Constructors
Name | Description |
---|---|
StringLengthAttribute(Int32) | Initializes a new StringLengthAttribute and specifies the maximum length. |
StringLengthAttribute(Int32, Int32) | Initializes a new StringLengthAttribute and specifies the maximum length and the minimum length. |
Properties
Name | Description |
---|---|
MaximumLength | Gets the maximum length. |
MinimumLength | Gets the minimum length. |
Methods
Name | Description |
---|---|
GetErrorMessage() | |
GetErrorMessageArguments() | |
ValidateValue(String, String, LocationKind, LocationValidationContext) | |
ValidateValueDynamic(Object, String, LocationKind, LocationValidationContext) | Validates a weakly-typed (boxed) value, typically the value of a dependency property or an attached property. |