コード例 #1
0
 public StrassenabschnittSplitModelValidator(ILocalizationService localizationService)
     : base(localizationService)
 {
     StrassenabschnittCommonModelValidator.ApplyRules(this, localizationService);
     RuleForNullableInt(m => m.Abschnittsnummer);
     RuleFor(m => m.Laenge)
     .NotNull()
     .InclusiveBetween(1, 50000)
     .IsValidDecimalWithDecimalPlaces(1, LocalizationService);
 }
コード例 #2
0
 public StrassenabschnittImportModelValidator(ILocalizationService localizationService, IStrassenabschnittService strassenabschnittService) : base(localizationService)
 {
     StrassenabschnittCommonModelValidator.ApplyRules(this, localizationService);
     RuleForNullableInt(m => m.Abschnittsnummer);
     RuleFor(m => m.Laenge)
     .NotNull()
     .InclusiveBetween(1, 50000)
     .IsValidDecimalWithDecimalPlaces(1, LocalizationService)
     .Must((m, p) => m.Laenge.HasValue && (m.Laenge.Value >= strassenabschnittService.GetSumOfZustandsabschnittLaenge(m.Id)))
     .WithMessage(localizationService.GetLocalizedError(ValidationError.StrassenabschnittZustandsabschnittLaengeError), m => m.Laenge);
 }
コード例 #3
0
 public StrassenabschnittModelValidator(ILocalizationService localizationService, IStrassenabschnittService strassenabschnittService) : base(localizationService)
 {
     StrassenabschnittCommonModelValidator.ApplyRules(this, localizationService);
     RuleForNullableInt(m => m.Abschnittsnummer);
     RuleFor(m => m.ExternalId).Must((model, propertyValue) => strassenabschnittService.IsUniqueId(propertyValue, model.Id))
     .When(m => !string.IsNullOrEmpty(m.ExternalId))
     .WithMessage(localizationService.GetLocalizedError(ValidationError.ShouldBeUnique));
     RuleFor(m => m.Laenge)
     .NotNull()
     .InclusiveBetween(1, 50000)
     .IsValidDecimalWithDecimalPlaces(1, LocalizationService)
     .Must((m, p) => m.Laenge.HasValue && (m.Laenge.Value >= strassenabschnittService.GetSumOfZustandsabschnittLaenge(m.Id)))
     .WithMessage(localizationService.GetLocalizedError(ValidationError.StrassenabschnittZustandsabschnittLaengeError), m => m.Laenge);
 }
コード例 #4
0
 public StrassenabschnittGISModelValidator(IGeoJSONParseService geoJSONParseService, ILocalizationService localizationService, IStrassenabschnittGISService strassenabschnittGISService)
     : base(localizationService)
 {
     StrassenabschnittCommonModelValidator.ApplyRules(this, localizationService);
     RuleFor(m => m.FeatureGeoJSONString).Must(json => json.HasText())
     .WithMessage(localizationService.GetLocalizedError(ValidationError.GeometryNull)).NotNull().NotEmpty();
     RuleForNullableInt(m => m.Abschnittsnummer);
     RuleFor(m => m.Laenge)
     .NotNull()
     .When(m => m.FeatureGeoJSONString.HasText())
     .InclusiveBetween(1, 50000)
     .When(m => m.FeatureGeoJSONString.HasText())
     .IsValidDecimalWithDecimalPlaces(1, LocalizationService)
     .When(m => m.FeatureGeoJSONString.HasText())
     .Must((m, p) => m.Laenge.HasValue && (m.Laenge.Value >= strassenabschnittGISService.GetSumOfZustandsabschnittLaenge(m.Id)))
     .WithMessage(localizationService.GetLocalizedError(ValidationError.StrassenabschnittZustandsabschnittLaengeError), m => m.Laenge)
     .When(m => m.FeatureGeoJSONString.HasText());
     RuleFor(m => m.FeatureGeoJSONString).Must(geoJSONParseService.isAbschnittGISModelBaseValid).When(m => m.FeatureGeoJSONString.HasText()).WithMessage(localizationService.GetLocalizedError(ValidationError.InvalidGeometry));
 }