dimanche 24 décembre 2017

send string parameter to regular expression

I have k model class that have a property with regular expression and mobile number pattern.

[Required(ErrorMessageResourceType = pattern, ErrorMessageResourceName = "PhoneNumberRequired")]
    [RegularExpression(new Delta.Common.Utility.Regex().pattern, ErrorMessageResourceType = typeof(Resources), ErrorMessageResourceName = "PhoneNumberNotRegular")]
    public string TelNumber { get; set; }

I have a Regex class that have a string property contains phone number pattern(the pattern in RegularExpression).but RegularExpression doesn't accept the "pattern". How can define a pattern and use it everywhere I want?

Aucun commentaire:

Enregistrer un commentaire