mirror of
https://github.com/Sonarr/Sonarr.git
synced 2025-03-25 22:00:54 +02:00
Support validation of collections in RestController
This commit is contained in:
parent
039d7775ed
commit
e893ca4f1c
@ -70,11 +70,15 @@ namespace Sonarr.Http.REST
|
||||
var skipValidate = skipAttribute?.Skip ?? false;
|
||||
var skipShared = skipAttribute?.SkipShared ?? false;
|
||||
|
||||
if (Request.Method == "POST" || Request.Method == "PUT")
|
||||
if (Request.Method is "POST" or "PUT")
|
||||
{
|
||||
var resourceArgs = context.ActionArguments.Values.Where(x => x.GetType() == typeof(TResource))
|
||||
.Select(x => x as TResource)
|
||||
.ToList();
|
||||
var resourceArgs = context.ActionArguments.Values
|
||||
.SelectMany(x => x switch
|
||||
{
|
||||
TResource single => new[] { single },
|
||||
IEnumerable<TResource> multiple => multiple,
|
||||
_ => Enumerable.Empty<TResource>()
|
||||
});
|
||||
|
||||
foreach (var resource in resourceArgs)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user