|
using System;
using System.Collections.Generic;
using System.Reflection;
using Cobalt.Validation.Validators;
namespace Cobalt.Validation
{
/// <summary>
/// Implements a RegexValidator for the property.
/// </summary>
public class RegexValidatorAttribute : ValidatorAttribute
{
private string regex;
/// <summary>
/// Gets the regular expression.
/// </summary>
/// <value>The regular expression.</value>
public string Regex
{
get { return this.regex; }
}
/// <summary>
/// Initializes a new instance of the <see cref="RegexValidatorAttribute"/> class.
/// </summary>
/// <param name="regex">The regular expression.</param>
public RegexValidatorAttribute(string regex)
{
this.regex = regex;
}
/// <summary>
/// Gets the validator.
/// </summary>
/// <param name="propertyInfo">The property info.</param>
/// <returns></returns>
public override Validator GetValidator(PropertyInfo propertyInfo)
{
return new RegexValidator(this.ErrorMessage, propertyInfo, this.regex);
}
}
}
|
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.
This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.
A list of licenses authors might use can be found here
I work at a financial services firm using mostly .NET. I enjoy my job immensely and love teaching, training, and mentoring younger developers.