20 lines
633 B
C#
20 lines
633 B
C#
|
8 years ago
|
|
||
|
7 years ago
|
using System;
|
||
|
|
using System.Reflection;
|
||
|
|
|
||
|
8 years ago
|
namespace Yavsc.Attributes.Validation
|
||
|
|
{
|
||
|
|
public class YaRegularExpression : System.ComponentModel.DataAnnotations.RegularExpressionAttribute {
|
||
|
|
public YaRegularExpression(string pattern): base (pattern)
|
||
|
|
{
|
||
|
|
this.ErrorMessage = pattern;
|
||
|
|
}
|
||
|
|
|
||
|
|
public override string FormatErrorMessage(string name)
|
||
|
|
{
|
||
|
7 years ago
|
var prop = this.ErrorMessageResourceType.GetProperty(ErrorMessageResourceName);
|
||
|
|
return (string) prop.GetValue(null, BindingFlags.Static, null, null, System.Globalization.CultureInfo.CurrentUICulture);
|
||
|
|
|
||
|
8 years ago
|
}
|
||
|
|
}
|
||
|
|
}
|