Example #1
0
        public static bool IsValid(this CSValidation o)
        {
            var result = new ValidationBase();

            if (o.Validations.Count > 0)
            {
                foreach (var val in o.Validations.Keys)
                {
                    ((CValidationAttribute)o.Validations[val]).SetValidation(o.Value, ref result);
                }
            }

            return(false);
        }
Example #2
0
        public static string GetValidationMessage(this object model, string propertyName)
        {
            Type type       = model.GetType();
            var  prp        = type.GetProperties().Where(x => x.Name == propertyName).First();
            var  attributes = (from y in prp.GetCustomAttributes(typeof(CValidationAttribute), true)

                               select(CValidationAttribute) y).ToList();


            ValidationBase vbase = new ValidationBase();
            var            val   = prp.GetValue(model);

            foreach (var k in attributes)
            {
                k.SetValidation(val, ref vbase);
            }

            return(string.Join("<br/>", vbase.ValidationMessages));
        }
Example #3
0
 public virtual void SetValidation(object value, ref ValidationBase validationResult)
 {
     throw new NotImplementedException();
 }
Example #4
0
 public override void SetValidation(object value, ref ValidationBase validationResult)
 {
     value.ValidateRegex_WithMsg(ExtentionMethods.RegexTypes.MailPattern, Message, validationResult);
 }
Example #5
0
 public override void SetValidation(object value, ref ValidationBase validationResult)
 {
     value.ValidateRegex_WithMsg(RegexPattern, Message, validationResult);
 }
Example #6
0
 public override void SetValidation(object value, ref ValidationBase validationResult)
 {
     value.ValidateMatch_WithMsg(MatchValue, Message, validationResult);
 }
Example #7
0
 public override void SetValidation(object value, ref ValidationBase validationResult)
 {
     value.ValidateNumberRange_WithMsg(null, Max, Message, validationResult);
 }
Example #8
0
 public override void SetValidation(object value, ref ValidationBase validationResult)
 {
     value.ValidateStringLengthRange_WithMsg(Min, null, Message, validationResult);
 }
Example #9
0
 public override void SetValidation(object value, ref ValidationBase validationResult)
 {
     value.ValidateRequiredField_WithMsg(Message, validationResult);
 }