arg <= default(TKey) produces
Operator
<=cannot be applied to operands of typeTKey.
public class ParameterIdValidator<TKey> : IEndpointFilter
where TKey : IEquatable<TKey>
{
public async ValueTask<object?> InvokeAsync(EndpointFilterInvocationContext context, EndpointFilterDelegate next)
{
Type type = typeof(TKey);
var arg = context.GetArgument<TKey>(0);
if
(
type == typeof(short) ||
type == typeof(ushort) ||
type == typeof(int) ||
type == typeof(uint) ||
type == typeof(long) ||
type == typeof(ulong)
)
{
if (arg <= default(TKey))
{
return Results.BadRequest("Id must be positive!");
}
}
return await next(context);
}
}
How to fix this problem?