Show / Hide Table of Contents

Class ZipCodeAttribute

Checks that a Zip code is correct depending on the country.

Inheritance
Object
Attribute
ValidationAttribute
ZipCodeAttribute
Inherited Members
ValidationAttribute.FormatErrorMessage(String)
ValidationAttribute.IsValid(Object)
System.ComponentModel.DataAnnotations.ValidationAttribute.GetValidationResult(System.Object, System.ComponentModel.DataAnnotations.ValidationContext)
System.ComponentModel.DataAnnotations.ValidationAttribute.Validate(System.Object, System.String)
ValidationAttribute.Validate(Object, ValidationContext)
System.ComponentModel.DataAnnotations.ValidationAttribute.ErrorMessageString
System.ComponentModel.DataAnnotations.ValidationAttribute.RequiresValidationContext
System.ComponentModel.DataAnnotations.ValidationAttribute.ErrorMessage
System.ComponentModel.DataAnnotations.ValidationAttribute.ErrorMessageResourceName
System.ComponentModel.DataAnnotations.ValidationAttribute.ErrorMessageResourceType
System.Attribute.GetCustomAttributes(System.Reflection.MemberInfo, System.Type)
System.Attribute.GetCustomAttributes(System.Reflection.MemberInfo, System.Type, System.Boolean)
System.Attribute.GetCustomAttributes(System.Reflection.MemberInfo)
Attribute.GetCustomAttributes(MemberInfo, Boolean)
Attribute.IsDefined(MemberInfo, Type)
Attribute.IsDefined(MemberInfo, Type, Boolean)
System.Attribute.GetCustomAttribute(System.Reflection.MemberInfo, System.Type)
System.Attribute.GetCustomAttribute(System.Reflection.MemberInfo, System.Type, System.Boolean)
System.Attribute.GetCustomAttributes(System.Reflection.ParameterInfo)
System.Attribute.GetCustomAttributes(System.Reflection.ParameterInfo, System.Type)
Attribute.GetCustomAttributes(ParameterInfo, Type, Boolean)
System.Attribute.GetCustomAttributes(System.Reflection.ParameterInfo, System.Boolean)
System.Attribute.IsDefined(System.Reflection.ParameterInfo, System.Type)
System.Attribute.IsDefined(System.Reflection.ParameterInfo, System.Type, System.Boolean)
System.Attribute.GetCustomAttribute(System.Reflection.ParameterInfo, System.Type)
System.Attribute.GetCustomAttribute(System.Reflection.ParameterInfo, System.Type, System.Boolean)
System.Attribute.GetCustomAttributes(System.Reflection.Module, System.Type)
System.Attribute.GetCustomAttributes(System.Reflection.Module)
System.Attribute.GetCustomAttributes(System.Reflection.Module, System.Boolean)
System.Attribute.GetCustomAttributes(System.Reflection.Module, System.Type, System.Boolean)
System.Attribute.IsDefined(System.Reflection.Module, System.Type)
System.Attribute.IsDefined(System.Reflection.Module, System.Type, System.Boolean)
System.Attribute.GetCustomAttribute(System.Reflection.Module, System.Type)
Attribute.GetCustomAttribute(Module, Type, Boolean)
System.Attribute.GetCustomAttributes(System.Reflection.Assembly, System.Type)
System.Attribute.GetCustomAttributes(System.Reflection.Assembly, System.Type, System.Boolean)
Attribute.GetCustomAttributes(Assembly)
System.Attribute.GetCustomAttributes(System.Reflection.Assembly, System.Boolean)
System.Attribute.IsDefined(System.Reflection.Assembly, System.Type)
System.Attribute.IsDefined(System.Reflection.Assembly, System.Type, System.Boolean)
System.Attribute.GetCustomAttribute(System.Reflection.Assembly, System.Type)
Attribute.GetCustomAttribute(Assembly, Type, Boolean)
System.Attribute.Equals(System.Object)
System.Attribute.GetHashCode()
System.Attribute.Match(System.Object)
System.Attribute.IsDefaultAttribute()
System.Attribute.System.Runtime.InteropServices._Attribute.GetTypeInfoCount(System.UInt32)
System.Attribute.System.Runtime.InteropServices._Attribute.GetTypeInfo(System.UInt32, System.UInt32, System.IntPtr)
System.Attribute.System.Runtime.InteropServices._Attribute.GetIDsOfNames(System.Guid, System.IntPtr, System.UInt32, System.UInt32, System.IntPtr)
System.Attribute.System.Runtime.InteropServices._Attribute.Invoke(System.UInt32, System.Guid, System.UInt32, System.Int16, System.IntPtr, System.IntPtr, System.IntPtr, System.IntPtr)
Attribute.TypeId
System.Object.ToString()
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetType()
Object.MemberwiseClone()
Namespace: IRM.ComponentModel.DataAnnotations
Assembly: IRM.dll
Syntax
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, AllowMultiple = true)]
public sealed class ZipCodeAttribute : ValidationAttribute, _Attribute

Constructors

ZipCodeAttribute()

Initializes a new instance of the ZipCodeAttribute class to always validate the zip as swedish.

Declaration
public ZipCodeAttribute()

ZipCodeAttribute(String)

Initializes a new instance of the ZipCodeAttribute class.

Declaration
public ZipCodeAttribute(string countryCodeProperty)
Parameters
String countryCodeProperty

The property that contains the 2 digit ISO country code or null to always use 'SE'.

Properties

CountryCodeProperty

Gets the name of the property that contains the ISO country code (2 digits).

Declaration
public string CountryCodeProperty { get; }
Property Value
String

Remarks

If the value of the country code is null or an empty string, 'SE' will be used default.

Required

Gets or sets if the zip code is required or not. CountryRule is default.

Declaration
public ZipCodeRequired Required { get; set; }
Property Value
ZipCodeRequired

Methods

IsValid(Object, ValidationContext)

Validates the specified value with respect to the current validation attribute.

Declaration
protected override ValidationResult IsValid(object value, ValidationContext validationContext)
Parameters
Object value

The value to validate.

System.ComponentModel.DataAnnotations.ValidationContext validationContext

The context information about the validation operation.

Returns
System.ComponentModel.DataAnnotations.ValidationResult

An instance of the System.ComponentModel.DataAnnotations.ValidationResult class.

Overrides
System.ComponentModel.DataAnnotations.ValidationAttribute.IsValid(System.Object, System.ComponentModel.DataAnnotations.ValidationContext)

Extension Methods

ObjectExtensions.DeepClone<T>(T)
AnnotationsExtensions.IsValid(Object)
Back to top Generated by DocFX