Open warrenbuckley opened 10 years ago
This is a sealed class so cannot inheritate, in two minds to do this then. Thoughts @kholm ?
Bumping a bit of an old thread, but was curious how this might work out...
Wondering if this is the right approach?
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, AllowMultiple = false)]
public class UmbracoPhoneAttribute : DataTypeAttribute
{
private static PhoneAttribute _wrapper = new PhoneAttribute();
public UmbracoPhoneAttribute(string errorMessageDictionaryKey)
: base(DataType.PhoneNumber)
{
this.ErrorMessage = UmbracoValidationHelper.GetDictionaryItem(errorMessageDictionaryKey);
_wrapper.ErrorMessage = this.ErrorMessage;
}
public override bool IsValid(object value)
{
return _wrapper.IsValid(value);
}
}
Not that I need this code myself at the moment, just had a programmer's itch to scratch ;-)
For reference, the source for PhoneAttribute
is here.
Hey @leekelleher this looks perfectly good to me mate and I would love a Pull Request if you want to do it.
I need to make/find time as there is an issue with these in a newer version of 7 as described on issue tracker, but as always I can never find the time to give all projects love, care & attention they need. So any contributions is more than welcome :+1:
@warrenbuckley I know exactly what you mean - I'm facing the same on my various projects :bowtie:
I'll see what I can do! :metal:
http://msdn.microsoft.com/en-us/library/system.componentmodel.dataannotations.phoneattribute(v=vs.110).aspx