mirror of
https://github.com/Sonarr/Sonarr.git
synced 2025-04-09 07:24:10 +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 skipValidate = skipAttribute?.Skip ?? false;
|
||||||
var skipShared = skipAttribute?.SkipShared ?? 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))
|
var resourceArgs = context.ActionArguments.Values
|
||||||
.Select(x => x as TResource)
|
.SelectMany(x => x switch
|
||||||
.ToList();
|
{
|
||||||
|
TResource single => new[] { single },
|
||||||
|
IEnumerable<TResource> multiple => multiple,
|
||||||
|
_ => Enumerable.Empty<TResource>()
|
||||||
|
});
|
||||||
|
|
||||||
foreach (var resource in resourceArgs)
|
foreach (var resource in resourceArgs)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user