feat: add an annotation to the data
This commit is contained in:
@ -6,7 +6,9 @@ using Mirea.Api.DataAccess.Application.Cqrs.Professor.Queries.GetProfessorDetail
|
||||
using Mirea.Api.DataAccess.Application.Cqrs.Professor.Queries.GetProfessorList;
|
||||
using Mirea.Api.Dto.Responses;
|
||||
using Mirea.Api.Endpoint.Common.Attributes;
|
||||
using Mirea.Api.Endpoint.Common.Exceptions;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
@ -24,7 +26,7 @@ public class ProfessorController(IMediator mediator) : BaseController
|
||||
/// <returns>A list of professors.</returns>
|
||||
[HttpGet]
|
||||
[BadRequestResponse]
|
||||
public async Task<ActionResult<List<ProfessorResponse>>> Get([FromQuery] int? page, [FromQuery] int? pageSize)
|
||||
public async Task<ActionResult<List<ProfessorResponse>>> Get([FromQuery][Range(0, int.MaxValue)] int? page, [FromQuery][Range(1, int.MaxValue)] int? pageSize)
|
||||
{
|
||||
var result = await mediator.Send(new GetProfessorListQuery()
|
||||
{
|
||||
@ -78,7 +80,7 @@ public class ProfessorController(IMediator mediator) : BaseController
|
||||
[HttpGet("{name:required}")]
|
||||
[BadRequestResponse]
|
||||
[NotFoundResponse]
|
||||
public async Task<ActionResult<List<ProfessorResponse>>> GetDetails(string name)
|
||||
public async Task<ActionResult<List<ProfessorResponse>>> GetDetails([MinLength(4)] string name)
|
||||
{
|
||||
if (string.IsNullOrEmpty(name) || name.Length < 4)
|
||||
throw new ControllerArgumentException($"The minimum number of characters is 4 (current: {name.Length}).");
|
||||
|
Reference in New Issue
Block a user