New: Use ISO 639-3 language codes in metadata profile

This commit is contained in:
ta264
2021-09-02 21:12:13 +01:00
parent 7c10f3a74d
commit 7a969a63e4
5 changed files with 20 additions and 3 deletions
@@ -1,6 +1,8 @@
using System.Collections.Generic;
using System.Linq;
using FluentValidation;
using Microsoft.AspNetCore.Mvc;
using NzbDrone.Common.Extensions;
using NzbDrone.Core.Profiles.Metadata;
using NzbDrone.Http.REST.Attributes;
using Readarr.Http;
@@ -17,6 +19,14 @@ namespace Readarr.Api.V1.Profiles.Metadata
{
_profileService = profileService;
SharedValidator.RuleFor(c => c.Name).NotEqual("None").WithMessage("'None' is a reserved profile name").NotEmpty();
SharedValidator.RuleFor(c => c.AllowedLanguages)
.Must(x => x
.Trim(',')
.Split(',')
.Select(y => y.Trim())
.All(y => y == "null" || NzbDrone.Core.Books.Calibre.Extensions.KnownLanguages.Contains(y)))
.When(x => x.AllowedLanguages.IsNotNullOrWhiteSpace())
.WithMessage("Unknown languages");
}
[RestPostById]