Activities of "Thiqah.Abp"

Still not working! Calling the generated conventional controller does not validae the input. However, after reading the documentation again and again, I figured the issue:

ABP framework uses the dynamic proxying / interception system to perform the validation. In order to make it working, your method should be virtual or your service should be injected and used over an interface (like IMyService).

https://docs.abp.io/en/abp/latest/Validation#validation-infrastructure

Our problem is that the Application Service Method is not virtual, after adding the virtual keyword to the method, it works.

hi

Can you share the full source code to reporduce the problem?

I have reproduced the case with just an empty template and a simple application service bellow:

In Application.Contracts project:

[DependsOn(typeof(AbpFluentValidationModule)] Added to Module class

//Dto
public class SampleInputDto : EntityDto<Guid>
{
    public string RegistrationNumber { get; set; }
}

//Validator
public class SampleInputValidator : AbstractValidator<SampleInputDto>
{
   public SampleInputValidator()
   {
      RuleFor(input => input.RegistrationNumber)
            .NotEmpty()
            .MaximumLength(25);
   }
}

//Application service Interface
public interface ISampleAppService
{
   Task AddAsync(SampleInputDto input);
}

In Application project:

public class SampleAppService : AbpFluentValidationDemoAppService, ISampleAppService
{
     [Route("add")]
     public Task AddAsync(SampleInputDto input)
     {
         return Task.CompletedTask;
     }
}

In HttpApi project (Controllers):

[Route("api/Sample")]
public class SampleController : AbpFluentValidationDemoController, ISampleAppService
{
     private readonly ISampleAppService _sampleService;

     public SampleController(ISampleAppService sampleService)
     {
         _sampleService = sampleService;
     }

    [HttpPost]
    [Route("add")]
    public Task AddAsync(SampleInputDto input)
    {
        return _sampleService.AddAsync(input);
    }
}
Showing 1 to 2 of 2 entries
Made with ❤️ on ABP v8.2.0-preview Updated on March 25, 2024, 15:11