uon-nuget / UoN.ExpressiveAnnotations.NetCore

Annotation-based conditional validation library.
Other
29 stars 12 forks source link

localization errromessage #30

Open kageja opened 4 years ago

kageja commented 4 years ago

Hi, I use SharedResource in asp.net core 3.1 and If I use RequiredIf with ErrorMessage, I can't get my text in different Language

Thanks in advance

Kazbek commented 4 years ago

May be it will help.

"System.InvalidOperationException" in Microsoft.Extensions.Caching.Memory.dll "System.ComponentModel.DataAnnotations.ValidationException" in Uon2.dll "System.ComponentModel.DataAnnotations.ValidationException" in System.Private.CoreLib.dll

This messages I get in UoN project.

My attribute: [RequiredIf(nameof(WorkType) + " == " + nameof(TargetWorkType) + "." + nameof(TargetWorkType.Done), ErrorMessage = "Укажите источник.")]

This work perfectly before I migrate to asp.net core 3.1.

Kazbek commented 4 years ago

@kageja try to put ".AddExpressiveAnnotations();" at beginning of ConfigureServices. Like this:

public void ConfigureServices(IServiceCollection services){ services.AddExpressiveAnnotations(); ...other code... }

It helps me.

rhianedavies commented 3 years ago

It doesn't work for me either - even if I try putting the services.AddExpressiveAnnotations(); in a number of different locations. It is very frustrating. I'm using .net core 2.2.