-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #216 from dlcs/feature/ignorePaintedResource
Ignore painted resource when items are also present
- Loading branch information
Showing
7 changed files
with
184 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 12 additions & 5 deletions
17
src/IIIFPresentation/API/Features/Manifest/Validators/PresentationManifestValidator.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,28 @@ | ||
using API.Infrastructure.Validation; | ||
using API.Settings; | ||
using Core.Helpers; | ||
using DLCS; | ||
using FluentValidation; | ||
using Microsoft.Extensions.Options; | ||
using Models.API.Manifest; | ||
|
||
namespace API.Features.Manifest.Validators; | ||
|
||
public class PresentationManifestValidator : AbstractValidator<PresentationManifest> | ||
{ | ||
public PresentationManifestValidator() | ||
public PresentationManifestValidator(IOptions<ApiSettings> options) | ||
{ | ||
var settings = options.Value; | ||
|
||
RuleFor(f => f.Parent).NotEmpty().WithMessage("Requires a 'parent' to be set"); | ||
RuleFor(f => f.Slug).NotEmpty().WithMessage("Requires a 'slug' to be set") | ||
.Must(slug => !SpecConstants.ProhibitedSlugs.Contains(slug!)) | ||
.WithMessage("'slug' cannot be one of prohibited terms: '{PropertyValue}'"); | ||
RuleFor(f => f.Items).Empty() | ||
.When(f => !f.PaintedResources.IsNullOrEmpty()) | ||
.WithMessage("The properties \"items\" and \"paintedResource\" cannot be used at the same time"); | ||
|
||
if (!settings.IgnorePaintedResourcesWithItems) | ||
{ | ||
RuleFor(f => f.Items).Empty() | ||
.When(f => !f.PaintedResources.IsNullOrEmpty()) | ||
.WithMessage("The properties \"items\" and \"paintedResource\" cannot be used at the same time"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters