public ZustandsabschnittModelValidator(ILocalizationService localizationService, IZustandsabschnittService zustandsabschnittService, IStrassenabschnittService strassenabschnittService) : base(localizationService) { ZustandsabschnittCommonModelValidator.ApplyRules(this, localizationService); RuleForNullableInt(m => m.Abschnittsnummer); RuleForNullableDecimal(m => m.Laenge) .NotNull() .Must((m, p) => m.Laenge.HasValue && zustandsabschnittService.IsZustandsabschnittLaengeValid(m.Strassenabschnitt, m.Id, m.Laenge.Value)) .WithMessage(localizationService.GetLocalizedError( ValidationError.StrassenabschnittZustandsabschnittLaengeError), m => strassenabschnittService.GetById(m.Strassenabschnitt).Laenge); }
public ZustandsabschnittGISModelValidator(IGeoJSONParseService geoJSONParseService, ILocalizationService localizationService, IZustandsabschnittGISService zustandsabschnittGISService, IStrassenabschnittGISService strassenabschnittGISService) : base(localizationService) { ZustandsabschnittCommonModelValidator.ApplyRules(this, localizationService); RuleFor(m => m.FeatureGeoJSONString).Must(json => json.HasText()).WithMessage(localizationService.GetLocalizedError(ValidationError.GeometryNull)).NotNull().NotEmpty(); RuleForNullableInt(m => m.Abschnittsnummer); RuleForNullableDecimal(m => m.Laenge) .NotNull() .Must((m, p) => m.Laenge.HasValue && zustandsabschnittGISService.IsZustandsabschnittLaengeValid(m.StrassenabschnittGIS, m.Id, m.Laenge.Value)) .When(m => m.FeatureGeoJSONString.HasText()) .WithMessage(localizationService.GetLocalizedError(ValidationError.StrassenabschnittZustandsabschnittLaengeError), m => strassenabschnittGISService.GetById(m.StrassenabschnittGIS).Laenge); RuleFor(m => m.FeatureGeoJSONString).Must(geoJSONParseService.isAbschnittGISModelBaseValid).When(m => m.FeatureGeoJSONString.HasText()).WithMessage(localizationService.GetLocalizedError(ValidationError.InvalidGeometry)); }