Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Phone #8

Open
warrenbuckley opened this issue Apr 28, 2014 · 4 comments
Open

Phone #8

warrenbuckley opened this issue Apr 28, 2014 · 4 comments

Comments

@warrenbuckley
Copy link
Owner

http://msdn.microsoft.com/en-us/library/system.componentmodel.dataannotations.phoneattribute(v=vs.110).aspx

@warrenbuckley
Copy link
Owner Author

This is a sealed class so cannot inheritate, in two minds to do this then.
Thoughts @kholm ?

@leekelleher
Copy link
Contributor

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.

@warrenbuckley
Copy link
Owner Author

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 👍

@leekelleher
Copy link
Contributor

@warrenbuckley I know exactly what you mean - I'm facing the same on my various projects :bowtie:

I'll see what I can do! 🤘

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants