Beispiel #1
0
 private static IRuleBuilderOptions <T, TProperty> WithRangeState <T, TProperty>(this IRuleBuilderOptions <T, TProperty> ruleBuilderOptions, string attributeName)
 {
     return(ruleBuilderOptions.WithState((t, p) =>
                                         new Dictionary <string, string>()
     {
         { attributeName, p?.ToString() },
     }));
 }
Beispiel #2
0
 private static IRuleBuilderOptions <T, IReadOnlyCollection <TProperty> > WithEntityOccurenceState <T, TProperty>(this IRuleBuilderOptions <T, IReadOnlyCollection <TProperty> > ruleBuilderOptions, string attributeName)
 {
     return(ruleBuilderOptions.WithState((t, p) =>
                                         new Dictionary <string, string>()
     {
         { ActualOccurrencesStateKey, p?.Count.ToString() ?? "0" },
     }));
 }
Beispiel #3
0
 public static IRuleBuilderOptions <T, TProperty> WithValidationContext <T, TProperty>(this IRuleBuilderOptions <T, TProperty> rule, ValidationSeverity validationSeverity)
 {
     return(rule.WithState(i =>
     {
         return new object[2] {
             ValidationStatus.Invalid, validationSeverity
         };
     }));
 }
Beispiel #4
0
 public static IRuleBuilderOptions <T, TProperty> WithValidationContext <T, TProperty>(this IRuleBuilderOptions <T, TProperty> rule, ValidationStatus validationStatus)
 {
     return(rule.WithState(i =>
     {
         return new object[2] {
             validationStatus, ValidationSeverity.Error
         };
     }));
 }
Beispiel #5
0
 public static IRuleBuilderOptions <T, TProperty> WithImportState <T, TRecord, TProperty>(this IRuleBuilderOptions <T, TProperty> rule, ImportRecord <TRecord> importRecord)
 {
     return(rule.WithState(_ => new ImportValidationState <TRecord> {
         InvalidRecord = importRecord
     }));
 }
 public static IRuleBuilderOptions <T, TProp> AsWarning <T, TProp>(this IRuleBuilderOptions <T, TProp> ruleBuilder)
 {
     return(ruleBuilder.WithState(v => NzbDroneValidationState.Warning));
 }
 public static IRuleBuilderOptions <RegisterModel, T> InvalidState <T>(this
                                                                       IRuleBuilderOptions <RegisterModel, T> builder)
 {
     return(builder.WithState(model => ResultCode.Identity_InvalidRegisterRequest));
 }
Beispiel #8
0
 /// <summary>
 /// Specifies a custom category associated with the validation failure when validation fails for this rule.
 /// </summary>
 public static IRuleBuilderOptions <T, TProperty> WithCategory <T, TProperty>(this IRuleBuilderOptions <T, TProperty> rule, string category)
 {
     Condition.Requires(category, nameof(category)).IsNotNullOrWhiteSpace();
     return(rule.WithState(x => $"category={category}"));
 }
 protected virtual IRuleBuilderOptions <T, string> HandleInvalidRegionLength(IRuleBuilderOptions <T, string> builder)
 {
     return(builder.WithState(model => DefaultInvalidRegionCode));
 }
 protected virtual IRuleBuilderOptions <T, string> HandleEmptyLang(IRuleBuilderOptions <T, string> builder)
 {
     return(builder.WithState(model => DefaultInvalidLangCode));
 }
Beispiel #11
0
 public static IRuleBuilderOptions <T, TProperty> WithSummaryMessage <T, TProperty>(this IRuleBuilderOptions <T, TProperty> rule, Func <T, object> messageProvider) => rule.WithState(messageProvider);
Beispiel #12
0
 /// <summary>
 /// Adds a message that will appear in the validation summary, in addition to the field-level message.
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <typeparam name="TProperty"></typeparam>
 /// <param name="rule"></param>
 /// <param name="message"></param>
 /// <returns></returns>
 public static IRuleBuilderOptions <T, TProperty> WithSummaryMessage <T, TProperty>(this IRuleBuilderOptions <T, TProperty> rule, string message) => rule.WithState(x => message);
Beispiel #13
0
 public static IRuleBuilderOptions <T, TProperty> AsWarning <T, TProperty>(this IRuleBuilderOptions <T, TProperty> rule)
 {
     return(rule.WithState <T, TProperty>(x => ValidationErrorLevel.Warning));
 }
Beispiel #14
0
 protected virtual IRuleBuilderOptions <T, IEnumerable <LModel> > HandleInvalidList(
     IRuleBuilderOptions <T, IEnumerable <LModel> > builder)
 {
     return(builder.WithState(model => DefaultInvalidListCode));
 }
Beispiel #15
0
 public static IRuleBuilderOptions <T, TProperty> WithErrorCode <T, TProperty>(this IRuleBuilderOptions <T, TProperty> rule, int code)
 {
     return(rule.WithState(x => code));
 }