示例#1
0
        public static bool ValidatePhoneNumber(Contact contact)
        {
            Type type = typeof(Contact);
            var  prop = type.GetProperty("PhoneNumber");

            RegExAttribute regExp = (RegExAttribute)prop.GetCustomAttribute(typeof(RegExAttribute));
            bool           result = regExp.CheckExp(contact.PhoneNumber);

            return(result);
        }
        public override bool IsValid(SoftwareMonkeys.SiteStarter.Entities.IEntity entity, System.Reflection.PropertyInfo property, SoftwareMonkeys.SiteStarter.Entities.IValidatePropertyAttribute attribute)
        {
            if (property.PropertyType != typeof(String))
            {
                throw new InvalidOperationException("Cannot validate email address because the property type is '" + property.PropertyType.Name + "' when it needs to be string.");
            }

            string value = GetStringValue(entity, property);

            RegExAttribute regExAttribute = (RegExAttribute)attribute;

            return(Regex.IsMatch(value, regExAttribute.Expression));
        }
 private static IRegExFacet Create(RegExAttribute attribute, ISpecification holder)
 {
     return(new RegExFacet(attribute.Validation, attribute.Format, attribute.CaseSensitive, attribute.Message, holder));
 }
示例#4
0
 private static IRegExFacet Create(RegExAttribute attribute, IFacetHolder holder) {
     return new RegExFacetAnnotation(attribute.Validation, attribute.Format, attribute.CaseSensitive, attribute.Message, holder);
 }
 private static IRegExFacet Create(RegExAttribute attribute, ISpecification holder) {
     return new RegExFacet(attribute.Validation, attribute.Format, attribute.CaseSensitive, attribute.Message, holder);
 }