MetalamaAPI documentationPatterns APIMetalama.​Patterns.​ContractsString­Length­Attribute
Open sandboxFocus

StringLengthAttribute Class

Custom attribute that, when added to a field, property or parameter, throws an ArgumentException if the target is assigned a string of invalid length. If the target is a nullable type, If the target is a nullable type, null strings are accepted and do not throw an exception.

Inheritance
System.Object
StringLengthAttribute
Namespace: Metalama.Patterns.Contracts
Assembly: Metalama.Patterns.Contracts.dll
Syntax
public sealed class StringLengthAttribute : ContractBaseAttribute, IAspect<IParameter>, IEligible<IParameter>, IAspect<IFieldOrPropertyOrIndexer>, IEligible<IFieldOrPropertyOrIndexer>, IConditionallyInheritableAspect, IAspect, ICompileTimeSerializable, ITemplateProvider

Constructors

Name Description
StringLengthAttribute(Int32)

Initializes a new instance of the StringLengthAttribute class.

StringLengthAttribute(Int32, Int32)

Initializes a new instance of the StringLengthAttribute class.

Properties

Name Description
MaximumLength

Gets the maximum length.

MinimumLength

Gets the minimum length.

Methods

Name Description
BuildEligibility(IEligibilityBuilder<IFieldOrPropertyOrIndexer>)
BuildEligibility(IEligibilityBuilder<IParameter>)
Validate(Object)

See Also