-
Notifications
You must be signed in to change notification settings - Fork 182
Open
Description
There is currently no way to validate query options without throwing an exception. I'd like a TryValidate method, so I don't need to catch an exception to find out that the query options don't satisfy the settings. Ideally it would have an out parameter which includes the disallowed query option.
public ActionResult< IQueryable > Get(
ODataQueryOptions< TResult > queryOptions )
{
ODataValidationSettings validationSettings =
new( )
{
AllowedQueryOptions = AllowedQueryOptions.Select | AllowedQueryOptions.SkipToken,
MaxTop = 1000,
};
try
{
queryOptions.Validate( validationSettings );
}
catch ( Exception )
{
return BadRequest( "Unsupported query option" );
}
}Reactions are currently unavailable