camelCase in Fluent validation in .Net 6 Web Api
Nested properties are PascalCase from Fluent Validation, how can i change it to be camelCase for nested objects/everything?
For the client I use React, I do not want to convert it client-side.
What i currently have is:
{
"name": [
"Navn på vin er påkrevd.",
"Navn på vin må minst være 3 bokstaver."
],
"type": [
"Type er påkrevd."
],
// What i want: userDetails.quantity
"userDetails.Quantity": [
"'user Details Quantity' must be between 0 and 2000. You entered -1."
]
}
What i want is userDetails.quantity not userDetails.Quantity
I have this in my Program.cs class
builder.Services.AddControllers()
.AddFluentValidation(fv =>
{
fv.RegisterValidatorsFromAssemblyContaining<AddWineValidator>();
})
.AddNewtonsoftJson(options =>
{
options.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
});
Well, I would suggest using fluentvalidation's PropertyNameResolver for the job. I think this issue on github directly answers your question.