Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RequiredIf error message support with shared localizer(for multi-language) in MVC project #203

Open
oznurco opened this issue Nov 9, 2019 · 1 comment

Comments

@oznurco
Copy link

oznurco commented Nov 9, 2019

Hi,
I added ExpressiveAnnotations to my MVC project. That works fine but I have a problem with different languages for the error message. If I use below notation in view model class for one attribute, the error message is shown different language. "RequiredAttribute_ValidationError" is exist shared localized file.
[Required(ErrorMessage = "RequiredAttribute_ValidationError")]

I use "[RequiredIf("name != null", ErrorMessage = "RequiredAttribute_ValidationError")]" notation in view model class, error message is shown as string "RequiredAttribute_ValidationError" in related field in Html page.
How to use "ExpressiveAnnotations" with multi-languages?

@okankocyigit
Copy link

Hi oznurco,

You have to use ErrorMessageResourceType and ErrorMessageResourceName parameters to localize your error message.

[RequiredIf("name != null", ErrorMessageResourceType = typeof(Resources), ErrorMessageResourceName = "RequiredAttribute_ValidationError")]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants