public async Task<ActionResult> GetCustomerById(int id)
{
var data = await _customerService.GetCustomerById(id);
return Ok(data);
}
how can we implement fluent validation for request parameter - id?
public async Task<ActionResult> GetCustomerById(int id)
{
var data = await _customerService.GetCustomerById(id);
return Ok(data);
}
how can we implement fluent validation for request parameter - id?
You can use it like this :
RuleFor(id => id).LessThan(100).GreaterThan(0);
You don't need FluentValidtion to validate the request, It's an Attribute Routing. It helps you to not process invalid request.
[HttpGet("GetCustomerById/{id:int:min(1)}")]
public async Task<ActionResult> GetCustomerById(int id)
{
}