✅ Help understanding validation magic in ASPNET WebAPI
imagine what, you fucking can't
65 Replies
cuz its 2024 and there's 99999 bilion into AI
but can't fix debugger
so I can actually follow the stack
where is the fucking validation hppening?
i think noone really knows
just fuck you microsfot
For an ASP.NET Core MVC app?
The naming... i think yes, but who knows?
lol i think yes
i ended up using
IValidatableObject
but still have no idea where its executed
I would really love to know how can I pass HttpRequest into Validate
Put breakpoints on property getters maybe
enable external sources debugging also
it's off by default because usually people don't look into how libraries work
How it works in short: it makes a metadata structure, then it goes through the attributes and stores ones that are for validation. If you go into Required, it will probably have a method for validation. There are some systems that let it add extra stuff, iirc (providers)
Don't do that in mvc validation btw
It's synchronous, don't access the db in there
All of that should be done manually
If you want to generalize that, you have to make a custom system for it
Unknown User•10mo ago
Message Not Public
Sign In & Join Server To View
thanks a lot Anton
yea and what comes back is exactly what makes it so confusing
all the information t hat search engines and ai brings is shit comapred to what Anton posted for example
cuz it requires deep understanding which docs dont provide
Unknown User•10mo ago
Message Not Public
Sign In & Join Server To View
as search engine
Unknown User•10mo ago
Message Not Public
Sign In & Join Server To View
its pretty good, but not with MSdocs
Unknown User•10mo ago
Message Not Public
Sign In & Join Server To View
its not enough data to properly understand the proiblem
Unknown User•10mo ago
Message Not Public
Sign In & Join Server To View
Unknown User•10mo ago
Message Not Public
Sign In & Join Server To View
TeBeCo
really ? which part ?
Quoted by
<@689473681302224947> from #✅ Help understanding validation magic in ASPNET WebAPI (click here)
React with ❌ to remove this embed.
Unknown User•10mo ago
Message Not Public
Sign In & Join Server To View
im not saying u have no point here
Unknown User•10mo ago
Message Not Public
Sign In & Join Server To View
thanks for sharing ill check this out
Unknown User•10mo ago
Message Not Public
Sign In & Join Server To View
ill check in debugger first with external sources
Unknown User•10mo ago
Message Not Public
Sign In & Join Server To View
That doc is mostly how to use it
Unknown User•10mo ago
Message Not Public
Sign In & Join Server To View
There is some info on the internals, but not enough to understand it to a reasonable extent
Unknown User•10mo ago
Message Not Public
Sign In & Join Server To View
hmm i have external sources enabled wondering if its the rider that cannot pickup and i should open visual studio
Unknown User•10mo ago
Message Not Public
Sign In & Join Server To View
Reading the code and possible stepping through code is more helpful in this case imo
Unknown User•10mo ago
Message Not Public
Sign In & Join Server To View
It should work in rider
Unknown User•10mo ago
Message Not Public
Sign In & Join Server To View
Where's your breakpoint at?
Unknown User•10mo ago
Message Not Public
Sign In & Join Server To View
yea but its just the design
Sure, it is pretty high level though
Unknown User•10mo ago
Message Not Public
Sign In & Join Server To View
i dont trust the image i want the code :d
Unknown User•10mo ago
Message Not Public
Sign In & Join Server To View
The docs are too high level to be able to understand how it ties together deeper
Unknown User•10mo ago
Message Not Public
Sign In & Join Server To View
Yeah probably, because the only thing that helped me when I needed a thing that had to do with that, I had to look at the sources
And I did read all that at some point
Unknown User•10mo ago
Message Not Public
Sign In & Join Server To View
Don't use the db context there, still
Unknown User•10mo ago
Message Not Public
Sign In & Join Server To View
MVC validation is synchronous
Unknown User•10mo ago
Message Not Public
Sign In & Join Server To View
Don't forget that minimal API doesn't have built-in validation, so you have to do something manually, or add an external dependency
im checking debugging in vs code now, with breakpoints on properties rider still has some problems
Unknown User•10mo ago
Message Not Public
Sign In & Join Server To View
I don't mean it's bad, just mentioning that they will need to depend on a lib for validation
Unknown User•10mo ago
Message Not Public
Sign In & Join Server To View
so can you both agree that MVC is the past ?
Unknown User•10mo ago
Message Not Public
Sign In & Join Server To View
can i get minimal api to work so well with swagger like the MVC controller?
Unknown User•10mo ago
Message Not Public
Sign In & Join Server To View
If you add your models as parameters to the request handler delegate, they will be visible in Swagger
It's more complicated otherwise
Well, it is kind of the same with mvc in this regard
maybe this is largely an XY problem? my problem, trying to find a linear reproducable way of correctly doing the APIS with some "OpenApi" auto genreated schema that can be reuysed by 3rd party utilizing the API
Unknown User•10mo ago
Message Not Public
Sign In & Join Server To View
One problem I have with their OpenAPI metadata abstractions, which I think both MVC and minimal API generate, is that they can't represent everything OpenAPI can, and you'll have easier time adjusting the schema generation with a filter sometimes. At least in my experience
Unknown User•10mo ago
Message Not Public
Sign In & Join Server To View
now I am lost which way would be the correct one damn you guys 😂
more questions than answers but back to the root of the topic i guess it makes sense thank you for info and patience to my stupid ass
Visual Studio debugger works fine
this makes sense
+ FluentValidation, + its explicit
and it wont be synchronous
+ i can use builtin openapi with swashbuckle still
thats where we will see how it works ou
Unknown User•10mo ago
Message Not Public
Sign In & Join Server To View
debugging in rider seems to work too but had to switch some inputs
perfect timing 🙂