Separate responsibilities: start-listening command, API-side JSON converters, bulk track endpoints, mix kinds
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
using FluentValidation;
|
||||
using Musify.Api.DataTransferObjects;
|
||||
|
||||
namespace Musify.Api.Validators;
|
||||
|
||||
public sealed class AddTracksRequestValidator : AbstractValidator<AddTracksRequest>
|
||||
{
|
||||
public const int MaxTracksPerRequest = 500;
|
||||
|
||||
public AddTracksRequestValidator()
|
||||
{
|
||||
RuleFor(x => x.TrackIds)
|
||||
.NotEmpty()
|
||||
.Must(ids => ids.Count <= MaxTracksPerRequest)
|
||||
.WithMessage($"At most {MaxTracksPerRequest} tracks can be added at once.");
|
||||
|
||||
RuleForEach(x => x.TrackIds)
|
||||
.NotEmpty();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using FluentValidation;
|
||||
using Musify.Api.DataTransferObjects.Tracks;
|
||||
|
||||
namespace Musify.Api.Validators.Tracks;
|
||||
|
||||
public sealed class RecordListeningProgressRequestValidator : AbstractValidator<RecordListeningProgressRequest>
|
||||
{
|
||||
public RecordListeningProgressRequestValidator()
|
||||
{
|
||||
RuleFor(x => x.PlayedSeconds)
|
||||
.Must(seconds => double.IsFinite(seconds) && seconds >= 0)
|
||||
.WithMessage("'Played Seconds' must be a non-negative number.");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user