简体   繁体   中英

Custom error format for fluent validation error

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM