© 2026 Hedgehog Software, LLC
Twitter
GitHub
Discord
System
Light
Dark
More
Communities
Docs
About
Terms
Privacy
Search
Star
Feedback
Setup for Free
C
C#
•
3y ago
•
30 replies
LazyGuard
❔ Prevent accepting numeric values as enum
Hello
, I have an API that exposes an enum field Vehicle
(Car
, Bike
, Truck
) in the POST
. The problem is that when I POST a request with a body
{"vehicle" :"1" }
{"vehicle" :"1" }
, it gets accepted and gets automatically converted to Vehicle
.Bike
.
. But something like
{"vehicle" :"bar" }
{"vehicle" :"bar" }
results in a bad request
, which is what I need
!
Any idea on how to
stop
parsing integer like enum values
?
C#
Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871
Members
View on Discord
Resources
ModelContextProtocol
ModelContextProtocol
MCP Server
Similar Threads
Was this page helpful?
Yes
No
Recent Announcements
Similar Threads
Duplicate enum values serialization problems
C
C# / help
2y ago
❔ Compare Enum Values with submitted value
C
C# / help
4y ago
Get values from an Enum class and perform checking
C
C# / help
4y ago