Skip to content

Commit 2b34ce1

Browse files
fix(*): remove all validations but required
1 parent e14e7eb commit 2b34ce1

22 files changed

+20
-89
lines changed

NorthwindCRUD/Controllers/CategoriesController.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
namespace NorthwindCRUD.Controllers
22
{
3-
using System.ComponentModel.DataAnnotations;
43
using AutoMapper;
54
using Microsoft.AspNetCore.Authorization;
65
using Microsoft.AspNetCore.Mvc;
76
using NorthwindCRUD.Models.DbModels;
87
using NorthwindCRUD.Models.Dtos;
98
using NorthwindCRUD.Services;
10-
using Swashbuckle.AspNetCore.Annotations;
119

1210
[ApiController]
1311
[Route("[controller]")]
@@ -52,8 +50,8 @@ public ActionResult<CategoryDto[]> GetAll()
5250
/// <returns>A PagedResultDto object containing the fetched T and the total record count.</returns>
5351
[HttpGet("GetCategoriesWithSkip")]
5452
public ActionResult<PagedResultDto<CategoryDto>> GetCategoriesWithSkip(
55-
[FromQuery][Attributes.SwaggerSkipParameter][Range(0, int.MaxValue)] int? skip,
56-
[FromQuery][Attributes.SwaggerTopParameter][Range(0, int.MaxValue)] int? top,
53+
[FromQuery][Attributes.SwaggerSkipParameter] int? skip,
54+
[FromQuery][Attributes.SwaggerTopParameter] int? top,
5755
[FromQuery][Attributes.SwaggerOrderByParameter] string? orderBy)
5856
{
5957
try

NorthwindCRUD/Controllers/CustomersController.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
namespace NorthwindCRUD.Controllers
22
{
3-
using System.ComponentModel.DataAnnotations;
43
using AutoMapper;
54
using Microsoft.AspNetCore.Authorization;
65
using Microsoft.AspNetCore.Mvc;
@@ -51,8 +50,8 @@ public ActionResult<CustomerDto[]> GetAll()
5150
/// <returns>A PagedResultDto object containing the fetched T and the total record count.</returns>
5251
[HttpGet("GetCustomersWithSkip")]
5352
public ActionResult<PagedResultDto<CustomerDto>> GetCustomersWithSkip(
54-
[FromQuery][Attributes.SwaggerSkipParameter][Range(0, int.MaxValue)] int? skip,
55-
[FromQuery][Attributes.SwaggerTopParameter][Range(0, int.MaxValue)] int? top,
53+
[FromQuery][Attributes.SwaggerSkipParameter] int? skip,
54+
[FromQuery][Attributes.SwaggerTopParameter] int? top,
5655
[FromQuery][Attributes.SwaggerOrderByParameter] string? orderBy)
5756
{
5857
try

NorthwindCRUD/Controllers/EmployeesController.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
namespace NorthwindCRUD.Controllers
22
{
3-
using System.ComponentModel.DataAnnotations;
43
using AutoMapper;
54
using Microsoft.AspNetCore.Authorization;
65
using Microsoft.AspNetCore.Mvc;
@@ -69,8 +68,8 @@ public ActionResult<OrderDto[]> GetAllAuthorized()
6968
/// <returns>A PagedResultDto object containing the fetched T and the total record count.</returns>
7069
[HttpGet("GetEmployeesWithSkip")]
7170
public ActionResult<PagedResultDto<EmployeeDto>> GetPagedEmployees(
72-
[FromQuery][Attributes.SwaggerSkipParameter][Range(0, int.MaxValue)] int? skip,
73-
[FromQuery][Attributes.SwaggerTopParameter][Range(0, int.MaxValue)] int? top,
71+
[FromQuery][Attributes.SwaggerSkipParameter] int? skip,
72+
[FromQuery][Attributes.SwaggerTopParameter] int? top,
7473
[FromQuery][Attributes.SwaggerOrderByParameter] string? orderBy)
7574
{
7675
try

NorthwindCRUD/Controllers/OrdersController.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
namespace NorthwindCRUD.Controllers
22
{
3-
using System.ComponentModel.DataAnnotations;
43
using AutoMapper;
54
using Microsoft.AspNetCore.Authorization;
65
using Microsoft.AspNetCore.Mvc;
@@ -57,8 +56,8 @@ public ActionResult<OrderDto[]> GetAll()
5756
/// <returns>A PagedResultDto object containing the fetched T and the total record count.</returns>
5857
[HttpGet("GetPagedOrders")]
5958
public ActionResult<PagedResultDto<OrderDto>> GetAllOrders(
60-
[FromQuery][Attributes.SwaggerSkipParameter][Range(0, int.MaxValue)] int? skip,
61-
[FromQuery][Attributes.SwaggerTopParameter][Range(0, int.MaxValue)] int? top,
59+
[FromQuery][Attributes.SwaggerSkipParameter] int? skip,
60+
[FromQuery][Attributes.SwaggerTopParameter] int? top,
6261
[FromQuery][Attributes.SwaggerOrderByParameter] string? orderBy)
6362
{
6463
try

NorthwindCRUD/Controllers/ProductsController.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
namespace NorthwindCRUD.Controllers
22
{
3-
using System.ComponentModel.DataAnnotations;
43
using AutoMapper;
54
using Microsoft.AspNetCore.Authorization;
65
using Microsoft.AspNetCore.Mvc;
@@ -71,8 +70,8 @@ public ActionResult<OrderDto[]> GetAllAuthorized()
7170
/// <returns>A PagedResultDto object containing the fetched T and the total record count.</returns>
7271
[HttpGet("GetPagedProducts")]
7372
public ActionResult<PagedResultDto<ProductDto>> GetAllProducts(
74-
[FromQuery][Attributes.SwaggerSkipParameter][Range(0, int.MaxValue)] int? skip,
75-
[FromQuery][Attributes.SwaggerTopParameter][Range(0, int.MaxValue)] int? top,
73+
[FromQuery][Attributes.SwaggerSkipParameter] int? skip,
74+
[FromQuery][Attributes.SwaggerTopParameter] int? top,
7675
[FromQuery][Attributes.SwaggerOrderByParameter] string? orderBy)
7776
{
7877
try

NorthwindCRUD/Controllers/RegionsController.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
namespace NorthwindCRUD.Controllers
22
{
3-
using System.ComponentModel.DataAnnotations;
43
using AutoMapper;
54
using Microsoft.AspNetCore.Authorization;
65
using Microsoft.AspNetCore.Mvc;
@@ -51,8 +50,8 @@ public ActionResult<RegionDto[]> GetAll()
5150
/// <returns>A PagedResultDto object containing the fetched T and the total record count.</returns>
5251
[HttpGet("GetPagedRegions")]
5352
public ActionResult<PagedResultDto<RegionDto>> GetAllRegions(
54-
[FromQuery][Attributes.SwaggerSkipParameter][Range(0, int.MaxValue)] int? skip,
55-
[FromQuery][Attributes.SwaggerTopParameter][Range(0, int.MaxValue)] int? top,
53+
[FromQuery][Attributes.SwaggerSkipParameter] int? skip,
54+
[FromQuery][Attributes.SwaggerTopParameter] int? top,
5655
[FromQuery][Attributes.SwaggerOrderByParameter] string? orderBy)
5756
{
5857
try

NorthwindCRUD/Controllers/ShippersController.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
namespace NorthwindCRUD.Controllers
22
{
3-
using System.ComponentModel.DataAnnotations;
43
using AutoMapper;
54
using Microsoft.AspNetCore.Authorization;
65
using Microsoft.AspNetCore.Mvc;
@@ -51,8 +50,8 @@ public ActionResult<ShipperDto[]> GetAll()
5150
/// <returns>A PagedResultDto object containing the fetched T and the total record count.</returns>
5251
[HttpGet("GetPagedShippersWithSkip")]
5352
public ActionResult<PagedResultDto<ShipperDto>> GetPagedShippersWithSkip(
54-
[FromQuery][Attributes.SwaggerSkipParameter][Range(0, int.MaxValue)] int? skip,
55-
[FromQuery][Attributes.SwaggerTopParameter][Range(0, int.MaxValue)] int? top,
53+
[FromQuery][Attributes.SwaggerSkipParameter] int? skip,
54+
[FromQuery][Attributes.SwaggerTopParameter] int? top,
5655
[FromQuery][Attributes.SwaggerOrderByParameter] string? orderBy)
5756
{
5857
try

NorthwindCRUD/Controllers/SuppliersController.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
namespace NorthwindCRUD.Controllers
22
{
3-
using System.ComponentModel.DataAnnotations;
43
using AutoMapper;
54
using Microsoft.AspNetCore.Authorization;
65
using Microsoft.AspNetCore.Mvc;
@@ -51,8 +50,8 @@ public ActionResult<SupplierDto[]> GetAll()
5150
/// <returns>A PagedResultDto object containing the fetched T and the total record count.</returns>
5251
[HttpGet("GetPagedSuppliers")]
5352
public ActionResult<PagedResultDto<SupplierDto>> GetAllSuppliers(
54-
[FromQuery][Attributes.SwaggerSkipParameter][Range(0, int.MaxValue)] int? skip,
55-
[FromQuery][Attributes.SwaggerTopParameter][Range(0, int.MaxValue)] int? top,
53+
[FromQuery][Attributes.SwaggerSkipParameter] int? skip,
54+
[FromQuery][Attributes.SwaggerTopParameter] int? top,
5655
[FromQuery][Attributes.SwaggerOrderByParameter] string? orderBy)
5756
{
5857
try

NorthwindCRUD/Controllers/TerritoriesController.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
namespace NorthwindCRUD.Controllers
22
{
3-
using System.ComponentModel.DataAnnotations;
43
using AutoMapper;
54
using Microsoft.AspNetCore.Authorization;
65
using Microsoft.AspNetCore.Mvc;
@@ -53,8 +52,8 @@ public ActionResult<TerritoryDto[]> GetAll()
5352
/// <returns>A PagedResultDto object containing the fetched T and the total record count.</returns>
5453
[HttpGet("GetPagedTerritories")]
5554
public ActionResult<PagedResultDto<TerritoryDto>> GetAllTerritories(
56-
[FromQuery][Attributes.SwaggerSkipParameter][Range(0, int.MaxValue)] int? skip,
57-
[FromQuery][Attributes.SwaggerTopParameter][Range(0, int.MaxValue)] int? top,
55+
[FromQuery][Attributes.SwaggerSkipParameter] int? skip,
56+
[FromQuery][Attributes.SwaggerTopParameter] int? top,
5857
[FromQuery][Attributes.SwaggerOrderByParameter] string? orderBy)
5958
{
6059
try

NorthwindCRUD/Models/Dtos/AddressDto.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,17 @@ namespace NorthwindCRUD.Models.Dtos
55
{
66
public class AddressDto : IAddress
77
{
8-
[StringLength(100, ErrorMessage = "Street cannot exceed 100 characters.")]
98
public string Street { get; set; }
109

11-
[StringLength(50, ErrorMessage = "City cannot exceed 50 characters.")]
1210
public string City { get; set; }
1311

14-
[StringLength(50, ErrorMessage = "Region cannot exceed 50 characters.")]
1512
public string Region { get; set; }
1613

17-
[StringLength(20, ErrorMessage = "Postal code cannot exceed 20 characters.")]
1814
public string PostalCode { get; set; }
1915

2016
[Required(ErrorMessage = "Country is required.")]
21-
[StringLength(50, ErrorMessage = "Country cannot exceed 50 characters.")]
2217
public string Country { get; set; }
2318

24-
[RegularExpression(@"^\+?\(?\d{1,5}\)?[-.\s]?\(?\d{1,5}\)?[-.\s]?\d{1,4}[-.\s]?\d{1,4}[-.\s]?\d{1,10}$", ErrorMessage = "Phone number is not valid.")]
2519
public string? Phone { get; set; }
2620
}
2721
}

0 commit comments

Comments
 (0)