Skip to content

Commit

Permalink
Use the CreateDto in all POST/PUT requests to avoid validation proble…
Browse files Browse the repository at this point in the history
…ms. (#92)
  • Loading branch information
Zifah authored Aug 15, 2024
1 parent 127767e commit f7475da
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 21 deletions.
2 changes: 0 additions & 2 deletions Application/Validation/CreateSuggestedNameValidator.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using Core.Dto.Request;
using Core.Dto.Response;
using Core.Enums;
using FluentValidation;

namespace Application.Validation
Expand Down
9 changes: 2 additions & 7 deletions Application/Validation/GeoLocationValidator.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
using Core.Dto.Response;
using Core.Dto.Request;
using Core.Repositories;
using FluentValidation;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Application.Validation
{
public class GeoLocationValidator : AbstractValidator<GeoLocationDto>
public class GeoLocationValidator : AbstractValidator<CreateGeoLocationDto>
{
private readonly IGeoLocationsRepository _geoLocationsRepository;

Expand Down
9 changes: 3 additions & 6 deletions Core/Dto/Request/CreateSuggestedNameDto.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@

using Core.Dto.Response;

namespace Core.Dto.Request;
namespace Core.Dto.Request;

public record CreateSuggestedNameDto
{
public string Name { get; init; }
public string Details { get; init; }
public string Email { get; init; }
public List<GeoLocationDto> GeoLocation { get; set; }
public List<CreateGeoLocationDto> GeoLocation { get; set; }
public CreateSuggestedNameDto()
{
GeoLocation = new List<GeoLocationDto>();
GeoLocation = new List<CreateGeoLocationDto>();
}

}
10 changes: 4 additions & 6 deletions Core/Dto/Request/NameDto.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using Core.Dto.Response;
using Core.Enums;
using System.ComponentModel.DataAnnotations;
using Core.Enums;

namespace Core.Dto.Request
{
Expand All @@ -14,7 +12,7 @@ public abstract class NameDto
public State? State { get; set; }
public List<EtymologyDto> Etymology { get; set; }
public List<EmbeddedVideoDto> Videos { get; set; }
public List<GeoLocationDto> GeoLocation { get; set; }
public List<CreateGeoLocationDto> GeoLocation { get; set; }

public CommaSeparatedString? FamousPeople { get; set; }

Expand All @@ -34,14 +32,14 @@ public NameDto(string name, string meaning)
Meaning = meaning ?? throw new ArgumentNullException(nameof(meaning));
Etymology = new List<EtymologyDto>();
Videos = new List<EmbeddedVideoDto>();
GeoLocation = new List<GeoLocationDto>();
GeoLocation = new List<CreateGeoLocationDto>();
}

public NameDto()
{
Etymology = new List<EtymologyDto>();
Videos = new List<EmbeddedVideoDto>();
GeoLocation = new List<GeoLocationDto>();
GeoLocation = new List<CreateGeoLocationDto>();
}
}
}

0 comments on commit f7475da

Please sign in to comment.