示例#1
0
        public static string GetErrorMessage(IValidatableComponent component, ComponentValidationRule rule)
        {
            if (!string.IsNullOrEmpty(rule.ErrorMessage))
            {
                return(string.Format(rule.ErrorMessage, component.FieldLabel));
            }

            switch (rule.Rule)
            {
            case EnumComponentValidationRule.Mandatory:
                return(string.Format("Please fill the {0} field", component.FieldLabel));

            case EnumComponentValidationRule.Number:
                return(string.Format("Please enter only number in the {0} field", component.FieldLabel));

            case EnumComponentValidationRule.Email:
                return(string.Format("Please enter a valid email for {0} field", component.FieldLabel));

            case EnumComponentValidationRule.Callback:
                return("");

            default:
                return("");
            }
        }
示例#2
0
 public ComponentValidationError(IValidatableComponent component, ComponentValidationRule rule)
 {
     Component = component;
     Rule      = rule;
 }