Eight routes under /albums covering the listing, the detail, the tracklist and the owner-only writes, wired to the same validation filter and ErrorOr mapping the playlists use.
22 lines
580 B
C#
22 lines
580 B
C#
using FluentValidation;
|
|
using Musify.Api.DataTransferObjects.Albums;
|
|
|
|
namespace Musify.Api.Validators.Albums;
|
|
|
|
public sealed class CreateAlbumRequestValidator : AbstractValidator<CreateAlbumRequest>
|
|
{
|
|
public CreateAlbumRequestValidator()
|
|
{
|
|
RuleFor(x => x.Title)
|
|
.NotEmpty()
|
|
.MaximumLength(200);
|
|
|
|
RuleFor(x => x.Description)
|
|
.MaximumLength(256);
|
|
|
|
RuleFor(x => x.ReleaseYear)
|
|
.InclusiveBetween(AlbumReleaseYear.Earliest, AlbumReleaseYear.Latest)
|
|
.When(x => x.ReleaseYear.HasValue);
|
|
}
|
|
}
|