[Request for help] Query arguments validation
See original GitHub issuel2db 1.10.2.
Use case: yesterday I found a subtle bug in own code caused by inserting a record with local time instead of utc.
As a proof we do not do this mistake again I want to add an assertion on L2db level that checks all queries and logs (or throws) if there’s non-utc datetime argument.
In other words, I want to be able to catch things like this:
await db.Samples.InsertAsync(() => new Sample()
{
Id = id,
CreatedDate = DateTime.Now, // Bug here
DeletedDate = DateTime.UtcNow,
Description = "..."
});
I’ve tried
db.MappingSchema.SetConverter<DateTime, DateTime>(dt => FailIfLocalTime(dt));
but the converter is called only for values from db and is not called for query arguments.
Can you suggest any api that will work for my scenario?
Environment details
linq2db version: 1.10.2 Database Server: MS SQL 2017 Database Provider: Syetem.Data.Sql Operating system: Windows 10 Framework version: .NET Framework 4.7.2
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Should I validate all query params GET request
Ideally you should validate ALL parameters you need and use only the validated data. You can validate it in controller ...
Read more >REST API: Validating request params in GET request?
If you have query string param secondaryId on a GET endpoint of a REST API which searches a resource by that secondaryId ,...
Read more >Spring Boot REST API Validate Query Parameters Examples
Guide and code examples to validate query parameters (request parameters) with Spring Boot and Jakarta Bean validation.
Read more >Query Parameters and String Validations - FastAPI
FastAPI allows you to declare additional information and validation for your parameters. Let's take this application as example: Python 3.10+ Python 3.6+.
Read more >Validation on the query parameter · Issue #694 · graphql- ...
I would like to know what is the best place to put validation to the input parameter for the query for example {...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@ig-sinicyn, as i know name is not used here.
doesn’t work too?