Skip to content

Commit ef5233f

Browse files
Merge pull request #2269 from ita-social-projects/feature/issue-1930
Feature/issue 1930
2 parents f59222a + 6111363 commit ef5233f

5 files changed

+118
-1
lines changed

Streetcode/Streetcode.BLL/Resources/SharedResource.FailedToValidateSharedResource.en-US.Designer.cs

Lines changed: 54 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Streetcode/Streetcode.BLL/Resources/SharedResource.FailedToValidateSharedResource.en-US.resx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,4 +207,7 @@
207207
<data name="InvalidPaginationParameters" xml:space="preserve">
208208
<value>Pagination parameters must be valid</value>
209209
</data>
210+
<data name="MustNotBeInPast" xml:space="preserve">
211+
<value>{0} must not be in the past.</value>
212+
</data>
210213
</root>

Streetcode/Streetcode.BLL/Resources/SharedResource.FailedToValidateSharedResource.uk-UA.Designer.cs

Lines changed: 54 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Streetcode/Streetcode.BLL/Resources/SharedResource.FailedToValidateSharedResource.uk-UA.resx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,4 +207,7 @@
207207
<data name="InvalidPaginationParameters" xml:space="preserve">
208208
<value>Параметри пагінації повинні бути коректними</value>
209209
</data>
210+
<data name="MustNotBeInPast" xml:space="preserve">
211+
<value>{0} не повинна бути у минулому.</value>
212+
</data>
210213
</root>

Streetcode/Streetcode.BLL/Validators/News/BaseNewsValidator.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,10 @@ public BaseNewsValidator(
3535
.MustAsync((imageId, token) => ValidationExtentions.HasExistingImage(_repositoryWrapper, imageId, token)).WithMessage(x => localizer["ImageDoesntExist", x.ImageId]);
3636

3737
RuleFor(x => x.CreationDate)
38-
.NotEmpty().WithMessage(x => localizer["IsRequired", fieldLocalizer["CreationDate"]]);
38+
.Cascade(CascadeMode.Stop)
39+
.NotEmpty().WithMessage(x => localizer["IsRequired", fieldLocalizer["CreationDate"]])
40+
.Must(date => date.Date >= DateTime.UtcNow.Date)
41+
.WithMessage(x => localizer["MustNotBeInPast", fieldLocalizer["CreationDate"]]);
3942

4043
RuleFor(x => x.URL)
4144
.NotEmpty().WithMessage(x => localizer["CannotBeEmpty", fieldLocalizer["TargetUrl"]])

0 commit comments

Comments
 (0)