You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
recyclarr/src/Common/YamlDotNet/CannotBeEmptyAttribute.cs

17 lines
447 B

using System.Collections;
using System.ComponentModel.DataAnnotations;
namespace Common.YamlDotNet;
[AttributeUsage(AttributeTargets.Property)]
// ReSharper disable once UnusedType.Global
public sealed class CannotBeEmptyAttribute : RequiredAttribute
{
public override bool IsValid(object? value)
{
return base.IsValid(value) &&
value is IEnumerable list &&
list.GetEnumerator().MoveNext();
}
}