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:"
Markdown supported.
Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)

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")]

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v10.8.0-preview. Updated on September 28, 2026, 11:44
1
ABP Assistant
🔐 You need to be logged in to use the chatbot. Please log in first.