Open Closed

regular expression with resource #4882


User avatar
0
fadijb created
  • ABP Framework version: v 7.1.1
  • UI type: MVC
  • DB provider: EF Core
  • Tiered (MVC): no
  • Exception message and stack trace: An unhandled exception occurred while processing the request. InvalidOperationException: The resource type 'Horizon.HRMS1.Localization.HRMS1Resource' does not have an accessible static property named 'MobileNoFormat'. System.ComponentModel.DataAnnotations.ValidationAttribute.SetResourceAccessorByPropertyLookup()

TargetInvocationException: Exception has been thrown by the target of an invocation. System.Reflection.MethodInvoker.Invoke(object obj, IntPtr* args, BindingFlags invokeAttr)

  • Steps to reproduce the issue:"

1 Answer(s)
  • User Avatar
    0
    berkansasmaz created
    Support Team .NET Developer

    Hi, you can change the resource by configuring AbpMvcDataAnnotationsLocalizationOptions in the first step I specified below:

    1-) AddAssemblyResource

    [DependsOn(
        //modules...
    )]
    public class MyWebModule : AbpModule
    {
        public override void PreConfigureServices(ServiceConfigurationContext context)
        {
            context.Services.PreConfigure<AbpMvcDataAnnotationsLocalizationOptions>(options =>
            {
                options.AddAssemblyResource(typeof(MyResource), typeof(MyWebModule).Assembly);
            });
        }
    }
    

    2-) Usage with RegularExpression attribute.

    [RegularExpression(@"^966.*", ErrorMessage="MobileNoFormat")]

Made with ❤️ on ABP v9.1.0-preview. Updated on December 26, 2024, 06:07