PostSharp.Patterns.Contracts Namespace
The PostSharp.Patterns.Contracts namespace contains ready-made contracts that validate fields, properties and parameters at runtime.
Classes
  ClassDescription
Public classContractLocalizedTextProvider
Base class for contract error messages providers.
Public classCreditCardAttribute
Custom attribute that, when added to a field, property or parameter, throws an ArgumentException if the target is assigned a value that is not a valid credit card number. Null strings are accepted and do not throw an exception.
Public classEmailAddressAttribute
Custom attribute that, when added to a field, property or parameter, throws an ArgumentException if the target is assigned a value that is not a valid email address. Null strings are accepted and do not throw an exception.
Public classEnumDataTypeAttribute
Custom attribute that, when added to a field, property or parameter, throws an ArgumentException if the target is assigned a value that is not a valid member of an enumeration.
Public classGreaterThanAttribute
Custom attribute that, when added to a field, property or parameter, throws an ArgumentOutOfRangeException if the target is assigned a value that is smaller than a given value.
Public classLessThanAttribute
Custom attribute that, when added to a field, property or parameter, throws an ArgumentOutOfRangeException if the target is assigned a value that is greater than a given value.
Public classLocationContractAttribute
Base class for other custom attributes in this namespace.
Public classNegativeAttribute
Custom attribute that, when added to a field, property or parameter, throws an ArgumentOutOfRangeException if the target is assigned a value greater than zero.
Public classNotEmptyAttribute
Custom attribute that, when added to a field, property or parameter, throws an ArgumentNullException if the target is assigned a null or empty value. The custom attributes can be added to locations of type String (where empty means zero characters) or ICollection (where empty means zero items).
Public classNotNullAttribute
Custom attribute that, when added to a field, property or parameter, throws an ArgumentNullException if the target is assigned a null value.
Public classPhoneAttribute
Custom attribute that, when added to a field, property or parameter, throws an ArgumentException if the target is assigned a value that is not a valid phone number. Null strings are accepted and do not throw an exception.
Public classPositiveAttribute
Custom attribute that, when added to a field, property or parameter, throws an ArgumentOutOfRangeException if the target is assigned a value smaller than zero.
Public classPostconditionFailedException
The exception that is thrown when a postcondition contract was not fulfilled by a method.
Public classRangeAttribute
Custom attribute that, when added to a field, property or parameter, throws an ArgumentOutOfRangeException if the target is assigned a value that is outside a given range.
Public classRegularExpressionAttribute
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.
Public classRequiredAttribute
Custom attribute that, when added to a field, property or parameter, throws an ArgumentNullException if the target is assigned a null value or an empty or white-space string.
Public classStrictlyGreaterThanAttribute
Custom attribute that, when added to a field, property or parameter, throws an ArgumentOutOfRangeException if the target is assigned a value that is smaller than or equal to a given value.
Public classStrictlyLessThanAttribute
Custom attribute that, when added to a field, property or parameter, throws an ArgumentOutOfRangeException if the target is assigned a value that is greater than or equal to a given value.
Public classStrictlyNegativeAttribute
Custom attribute that, when added to a field, property or parameter, throws an ArgumentOutOfRangeException if the target is assigned a value greater than or equal to zero.
Public classStrictlyPositiveAttribute
Custom attribute that, when added to a field, property or parameter, throws an ArgumentOutOfRangeException if the target is assigned a value smaller than or equal to zero.
Public classStringLengthAttribute
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.
Public classUrlAttribute
Custom attribute that, when added to a field, property or parameter, throws an ArgumentException if the target is assigned a value that is not a valid URL starting with http://, https:// or ftp://. Null strings are accepted and do not throw an exception.