-
Notifications
You must be signed in to change notification settings - Fork 178
Add TryValidate for ODataQueryOptions #1485
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
/AzurePipelines run OData-AspNetCoreOData-main-rolling-1ES |
No pipelines are associated with this pull request. |
/AzurePipelines run OData-AspNetCoreOData-main-rolling-1ES |
No pipelines are associated with this pull request. |
/AzurePipelines run OData-AspNetCoreOData-main-rolling-1ES |
No pipelines are associated with this pull request. |
/// <param name="validationSettings">The validation settings.</param> | ||
/// <param name="validationErrors">Contains a collection of validation errors encountered, or an empty collection if validation succeeds.</param> | ||
/// <returns><see langword="true"/> if the validation succeeded; otherwise, <see langword="false"/>.</returns> | ||
bool TryValidate(ComputeQueryOption computeQueryOption, ODataValidationSettings validationSettings, out IEnumerable<string> validationErrors); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this pattern, shall we call 'Validate' within 'TryValidate' and avoid duplicate the validation codes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To avoid breaking changes, can we use the default interface method so we don't avoid the breaking changes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it the time to add 'async' interface method?
Issues
This pull request fixes #1419.
Description
This PR introduces a
TryValidate
methods toODataQueryOptions
addressing the current limitation where query options can only be validated by throwing exceptions.The
TryValidate
method provides a way to validate query options without relying on exception handling. Instead of relying on exception handling, this method returns a bool indicating success or failure and provides detailed validation errors through an out parameter.Example Usage:
Checklist (Uncheck if it is not completed)
Additional work necessary
If documentation update is needed, please add "Docs Needed" label to the issue and provide details about the required document change in the issue.