* replace playout externaljsonfile and templatefile with schedulefile * add scripted schedule-based playout * wip - not functional yet * temp disable scripted playout creation * allow fast-forwarding block playouts * add xmltv block behavior setting
31 lines
1.0 KiB
C#
31 lines
1.0 KiB
C#
using ErsatzTV.ViewModels;
|
|
using FluentValidation;
|
|
using FluentValidation.Results;
|
|
|
|
namespace ErsatzTV.Validators;
|
|
|
|
public class PlayoutEditViewModelValidator : AbstractValidator<PlayoutEditViewModel>
|
|
{
|
|
public PlayoutEditViewModelValidator()
|
|
{
|
|
RuleFor(p => p.Channel).NotNull();
|
|
RuleFor(p => p.ProgramSchedule).NotNull().When(p => string.IsNullOrWhiteSpace(p.Kind));
|
|
RuleFor(p => p.ScheduleFile).NotNull().When(p =>
|
|
p.Kind is PlayoutKind.ExternalJson or PlayoutKind.Sequential or PlayoutKind.Scripted);
|
|
}
|
|
|
|
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
|
|
{
|
|
ValidationResult result = await ValidateAsync(
|
|
ValidationContext<PlayoutEditViewModel>.CreateWithOptions(
|
|
(PlayoutEditViewModel)model,
|
|
x => x.IncludeProperties(propertyName)));
|
|
if (result.IsValid)
|
|
{
|
|
return [];
|
|
}
|
|
|
|
return result.Errors.Select(e => e.ErrorMessage);
|
|
};
|
|
}
|