|
using System;
using System.Collections.Generic;
using System.Text;
namespace System.Core.Validation
{
public class LengthValidatorAttribute : ValidatorAttributeBase
{
private uint _minLength;
private uint _maxLength;
/// <summary>
/// Initializes a new instance of the <see cref="LengthValidatorAttribute"/> class.
/// </summary>
/// <param name="maxLength">The maximum length.</param>
public LengthValidatorAttribute(uint maxLength)
: this(uint.MinValue, maxLength)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="LengthValidatorAttribute"/> class.
/// </summary>
/// <param name="minLength">The minimum length..</param>
/// <param name="maxLength">The maximum length.</param>
public LengthValidatorAttribute(uint minLength, uint maxLength)
{
_minLength = minLength;
_maxLength = maxLength;
}
public override ValidatorBase CreateValidator(Type propertyType, string propertyName)
{
return new LengthValidator(propertyType, propertyName, ErrorMessage, _minLength, _maxLength);
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
I'm a 39 year old software developer living in Norway.
I'm currently working for a software company making software for the retail industry.