public static RuleValidationMemberBuilder <T, TProperty> WithErrorMessage <T, TProperty>( this CurrentValidatorHolder <T, TProperty> obj, string code, string message, params Func <T, object>[] funcs) { obj.CurrentValidator.AddArguments(funcs.Select(func => (Func <object, object>)(x => func((T)x)))); obj.CurrentValidator.SetMessageSource(() => new ErrorRuleMessage(new MessageIdentity(code), message)); return((RuleValidationMemberBuilder <T, TProperty>)obj); }
public static RuleValidationMemberBuilder <T, TProperty> WithWarningMessage <T, TProperty>( this CurrentValidatorHolder <T, TProperty> obj, Func <T, object> customState, string message, params Func <T, object>[] funcs) { obj.CurrentValidator.AddArguments(funcs.Select(func => (Func <object, object>)(x => func((T)x)))); obj.CurrentValidator.SetState(x => customState((T)x)); obj.CurrentValidator.SetMessageSource(() => new WarningRuleMessage(new MessageIdentity(Guid.NewGuid() .ToString()), message)); return((RuleValidationMemberBuilder <T, TProperty>)obj); }
public static RuleValidationMemberBuilder <T, TProperty> WithCustomMessage <T, TProperty>( this CurrentValidatorHolder <T, TProperty> obj, Func <T, object> customState, Func <IRuleMessage> customRuleMessage, params Func <T, object>[] funcs) { obj.CurrentValidator.AddArguments(funcs.Select(func => (Func <object, object>)(x => func((T)x)))); obj.CurrentValidator.SetState(x => customState((T)x)); obj.CurrentValidator.SetMessageSource(customRuleMessage); return((RuleValidationMemberBuilder <T, TProperty>)obj); }