Exemple #1
0
        public static string ToScript(this CSValidation o, string selector, string group = "", string notValid = "", string valid = "")
        {
            var result = "";

            if (o.Validations.Count > 0)
            {
                foreach (var val in o.Validations.Keys)
                {
                    result += "." + ((CValidationAttribute)o.Validations[val]).ToString();
                }
            }

            if (!string.IsNullOrEmpty(group))
            {
                group = ".group('" + group + "')";
            }
            else
            {
                group += "";
            }

            result = string.Format("validation{0}{1}.set('{2}')", result,
                                   (notValid == "" ? "" : ".notValid(" + notValid + ")") +
                                   (valid == "" ? "" : ".valid(" + valid + ")") + group,
                                   selector);

            return(result);
        }
Exemple #2
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);
        }
Exemple #3
0
        public static CSValidation CheckValidation <ValidationType>(this object o, ValidationType validationParams) where ValidationType : CValidationAttribute
        {
            if (o != null && o.GetType() == typeof(CSValidation))
            {
                ((CSValidation)o).Validations.Add(((CValidationAttribute)validationParams).Mode, validationParams);
                return((CSValidation)o);
            }
            else
            {
                var csValidation = new CSValidation();
                csValidation.Value = o;
                csValidation.Validations.Add(((CValidationAttribute)validationParams).Mode, validationParams);

                return(csValidation);
            }
        }