/// <summary> /// The not null and not empty. /// </summary> /// <param name="ruleBuilder"> /// The rule builder. /// </param> /// <typeparam name="T"> /// </typeparam> /// <typeparam name="TProperty"> /// </typeparam> /// <returns> /// The <see cref="IRuleBuilderOptions"/>. /// </returns> public static IRuleBuilderOptions <T, TProperty> NotNullAndNotEmpty <T, TProperty>(this IRuleBuilderInitial <T, TProperty> ruleBuilder) { return (ruleBuilder.NotNull() .WithMessage(CustomMessages.EmptyField) .NotEmpty() .WithMessage(CustomMessages.EmptyField)); }
public static void Duration <T>(this IRuleBuilderInitial <T, int?> field) { field .NotNull() .WithMessageFromErrorCode("COURSERUN_DURATION_REQUIRED") .Must(c => !c.HasValue || (c.Value < 1000 && c.Value > 0)) .WithMessageFromErrorCode("COURSERUN_DURATION_RANGE"); }
/// <summary> /// String.IsNullOrEmpty() /// </summary> /// <typeparam name="T"></typeparam> /// <param name="ruleBuilderInitial"></param> /// <returns></returns> public static IRuleBuilderInitial <T, string> NotNullOrEmpty <T>(this IRuleBuilderInitial <T, string> ruleBuilderInitial) { ruleBuilderInitial .NotNull() .NotEmpty() .WithMessage("{PropertyName}不能为空"); return(ruleBuilderInitial); }
public static void NationalDelivery <T>(this IRuleBuilderInitial <T, bool?> field, Func <T, CourseDeliveryMode?> getDeliveryMode) { field // Required for work based delivery mode .NotNull() .When(t => getDeliveryMode(t) == CourseDeliveryMode.WorkBased, ApplyConditionTo.CurrentValidator) .WithMessageFromErrorCode("COURSERUN_NATIONAL_DELIVERY_REQUIRED") // Not allowed for delivery modes other than work based .Null() .When( t => { var deliveryMode = getDeliveryMode(t); return(deliveryMode.HasValue && deliveryMode != CourseDeliveryMode.WorkBased); }, ApplyConditionTo.CurrentValidator) .WithMessageFromErrorCode("COURSERUN_NATIONAL_DELIVERY_NOT_ALLOWED"); }
/// <summary> /// The catalog is null. /// </summary> /// <param name="ruleBuilder"> /// The rule builder. /// </param> /// <typeparam name="T"> /// </typeparam> /// <typeparam name="TProperty"> /// </typeparam> /// <returns> /// The <see cref="IRuleBuilderOptions"/>. /// </returns> public static IRuleBuilderOptions <T, TProperty> CatalogIsNull <T, TProperty>(this IRuleBuilderInitial <T, TProperty> ruleBuilder) { return(ruleBuilder.NotNull().WithMessage(CustomMessages.AcatalogIsNull)); }
public static void DurationUnit <T>(this IRuleBuilderInitial <T, CourseDurationUnit?> field) { field .NotNull() .WithMessageFromErrorCode("COURSERUN_DURATION_UNIT_REQUIRED"); }
public static void DeliveryMode <T>(this IRuleBuilderInitial <T, CourseDeliveryMode?> field) { field .NotNull() .WithMessageFromErrorCode("COURSERUN_DELIVERY_MODE_REQUIRED"); }
public static void FlexibleStartDate <T>(this IRuleBuilderInitial <T, bool?> field) { field .NotNull() .WithMessageFromErrorCode("COURSERUN_FLEXIBLE_START_DATE_REQUIRED"); }
public static IRuleBuilderOptions <T, TElement> Required <T, TElement>(this IRuleBuilderInitial <T, TElement> ruleBuilder) { return(ruleBuilder.NotNull().NotEmpty()); }
public static void StandardVersion <T>(this IRuleBuilderInitial <T, int?> field) => field .NotNull() .WithMessageFromErrorCode("APPRENTICESHIP_STANDARD_VERSION_REQUIRED");
public static void DeliveryMethod <T>(this IRuleBuilderInitial <T, ApprenticeshipLocationType?> field) { field .NotNull() .WithErrorCode("APPRENTICESHIP_DELIVERY_METHOD_REQUIRED"); }