Custom error format for fluent validation error

1.2k Views Asked by At

I followed Fluent documentation and I haven't found any option to overwrite default error format that is something like "'{propertyName}' must be something.". I have many validators and I won't rewrite them to .WithMessage("...").

Is there any option to change default message format?

I would like to have a similar interface to PropertyNameResolver that offers smart interface to change property name.

1

There are 1 best solutions below

0
On

You can overwrite the messages globally by modifying the ValidatorOptions.ResourceProviderType as noted on the localization page.

You only have to define the strings that you would like to change as it will use the default string if no override is specified.