Skip to content

Commit

Permalink
Merge branch 'develop' into feature/ARPA-910-add-news-title-to-endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfgangroese committed Jun 22, 2023
2 parents 7fd7fca + 8882059 commit d944a44
Show file tree
Hide file tree
Showing 15 changed files with 158 additions and 143 deletions.
1 change: 1 addition & 0 deletions Orso.Arpa.Api/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ private static void ConfigureValidation(IServiceCollection services)
.AddFluentValidationClientsideAdapters()
.AddValidatorsFromAssemblyContaining<LoginDtoValidator>()
.AddValidatorsFromAssemblyContaining<Validator>();
ValidatorOptions.Global.DefaultRuleLevelCascadeMode = CascadeMode.Stop;
}

private static void ConfigureAuthorization(IServiceCollection services)
Expand Down
23 changes: 10 additions & 13 deletions Orso.Arpa.Application/AddressApplication/PersonAddressCreateDto.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class PersonAddressCreateDtoMappingProfile : Profile
{
public PersonAddressCreateDtoMappingProfile()
{
CreateMap<PersonAddressCreateDto, Create.Command>()
_ = CreateMap<PersonAddressCreateDto, Create.Command>()
.ForMember(dest => dest.PersonId, opt => opt.MapFrom(src => src.Id))
.ForMember(dest => dest.Address1, opt => opt.MapFrom(src => src.Body.Address1))
.ForMember(dest => dest.Address2, opt => opt.MapFrom(src => src.Body.Address2))
Expand All @@ -46,42 +46,39 @@ public class PersonAddressCreateDtoValidator : IdFromRouteDtoValidator<PersonAdd
{
public PersonAddressCreateDtoValidator()
{
RuleFor(d => d.Body)
_ = RuleFor(d => d.Body)
.SetValidator(new PersonAddressCreateBodyDtoValidator());
}
}
public class PersonAddressCreateBodyDtoValidator : AbstractValidator<PersonAddressCreateBodyDto>
{
public PersonAddressCreateBodyDtoValidator()
{
RuleFor(c => c.Country)
.Cascade(CascadeMode.Stop)
_ = RuleFor(c => c.Country)
.NotEmpty()
.PlaceName(100);

RuleFor(c => c.City)
.Cascade(CascadeMode.Stop)
_ = RuleFor(c => c.City)
.NotEmpty()
.PlaceName(100);

RuleFor(c => c.Zip)
.Cascade(CascadeMode.Stop)
_ = RuleFor(c => c.Zip)
.NotEmpty()
.PlaceName(20);

RuleFor(c => c.Address1)
_ = RuleFor(c => c.Address1)
.PlaceName(100);

RuleFor(c => c.Address2)
_ = RuleFor(c => c.Address2)
.PlaceName(100);

RuleFor(c => c.State)
_ = RuleFor(c => c.State)
.PlaceName(100);

RuleFor(c => c.UrbanDistrict)
_ = RuleFor(c => c.UrbanDistrict)
.PlaceName(100);

RuleFor(c => c.CommentInner)
_ = RuleFor(c => c.CommentInner)
.RestrictedFreeText(500);
}
}
Expand Down
25 changes: 11 additions & 14 deletions Orso.Arpa.Application/AddressApplication/PersonAddressModifyDto.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class PersonAddressModifyDtoMappingProfile : Profile
{
public PersonAddressModifyDtoMappingProfile()
{
CreateMap<PersonAddressModifyDto, Modify.Command>()
_ = CreateMap<PersonAddressModifyDto, Modify.Command>()
.ForMember(dest => dest.PersonId, opt => opt.MapFrom(src => src.Id))
.ForMember(dest => dest.Id, opt => opt.MapFrom(src => src.AddressId))
.ForMember(dest => dest.Address1, opt => opt.MapFrom(src => src.Body.Address1))
Expand All @@ -49,10 +49,10 @@ public class PersonAddressModifyDtoValidator : IdFromRouteDtoValidator<PersonAdd
{
public PersonAddressModifyDtoValidator()
{
RuleFor(d => d.Body)
_ = RuleFor(d => d.Body)
.SetValidator(new PersonAddressModifyBodyDtoValidator());

RuleFor(dto => dto.AddressId)
_ = RuleFor(dto => dto.AddressId)
.NotEmpty();
}
}
Expand All @@ -61,34 +61,31 @@ public class PersonAddressModifyBodyDtoValidator : AbstractValidator<PersonAddre
{
public PersonAddressModifyBodyDtoValidator()
{
RuleFor(c => c.Country)
.Cascade(CascadeMode.Stop)
_ = RuleFor(c => c.Country)
.NotEmpty()
.PlaceName(100);

RuleFor(c => c.City)
.Cascade(CascadeMode.Stop)
_ = RuleFor(c => c.City)
.NotEmpty()
.PlaceName(100);

RuleFor(c => c.Zip)
.Cascade(CascadeMode.Stop)
_ = RuleFor(c => c.Zip)
.NotEmpty()
.PlaceName(20);

RuleFor(c => c.Address1)
_ = RuleFor(c => c.Address1)
.PlaceName(100);

RuleFor(c => c.Address2)
_ = RuleFor(c => c.Address2)
.PlaceName(100);

RuleFor(c => c.State)
_ = RuleFor(c => c.State)
.PlaceName(100);

RuleFor(c => c.UrbanDistrict)
_ = RuleFor(c => c.UrbanDistrict)
.PlaceName(100);

RuleFor(c => c.CommentInner)
_ = RuleFor(c => c.CommentInner)
.RestrictedFreeText(500);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class BankAccountCreateDtoMappingProfile : Profile
{
public BankAccountCreateDtoMappingProfile()
{
CreateMap<BankAccountCreateDto, Command>()
_ = CreateMap<BankAccountCreateDto, Command>()
.ForMember(dest => dest.PersonId, opt => opt.MapFrom(src => src.Id))
.ForMember(dest => dest.Iban, opt => opt.MapFrom(src => src.Body.Iban))
.ForMember(dest => dest.Bic, opt => opt.MapFrom(src => src.Body.Bic))
Expand All @@ -35,30 +35,28 @@ public class BankAccountCreateDtoValidator : IdFromRouteDtoValidator<BankAccount
{
public BankAccountCreateDtoValidator()
{
RuleFor(d => d.Body)
_ = RuleFor(d => d.Body)
.SetValidator(new BankAccountCreateBodyDtoValidator());
}
}
public class BankAccountCreateBodyDtoValidator : AbstractValidator<BankAccountCreateBodyDto>
{
public BankAccountCreateBodyDtoValidator()
{
RuleFor(c => c.Iban)
.Cascade(CascadeMode.Stop)
_ = RuleFor(c => c.Iban)
.NotEmpty()
.Iban();

RuleFor(c => c.Bic)
.Cascade(CascadeMode.Stop)
_ = RuleFor(c => c.Bic)
.NotEmpty()
.When(dto => !dto.Iban.StartsWith("de", StringComparison.InvariantCultureIgnoreCase), ApplyConditionTo.CurrentValidator)
.Bic()
.When(dto => !string.IsNullOrWhiteSpace(dto.Bic), ApplyConditionTo.CurrentValidator);

RuleFor(c => c.CommentInner)
_ = RuleFor(c => c.CommentInner)
.RestrictedFreeText(500);

RuleFor(c => c.AccountOwner)
_ = RuleFor(c => c.AccountOwner)
.PersonName(50);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class BankAccountModifyDtoMappingProfile : Profile
{
public BankAccountModifyDtoMappingProfile()
{
CreateMap<BankAccountModifyDto, Command>()
_ = CreateMap<BankAccountModifyDto, Command>()
.ForMember(dest => dest.PersonId, opt => opt.MapFrom(src => src.Id))
.ForMember(dest => dest.Iban, opt => opt.MapFrom(src => src.Body.Iban))
.ForMember(dest => dest.Bic, opt => opt.MapFrom(src => src.Body.Bic))
Expand All @@ -42,10 +42,10 @@ public class BankAccountModifyDtoValidator : IdFromRouteDtoValidator<BankAccount
{
public BankAccountModifyDtoValidator()
{
RuleFor(d => d.Body)
_ = RuleFor(d => d.Body)
.SetValidator(new BankAccountModifyBodyDtoValidator());

RuleFor(dto => dto.BankAccountId)
_ = RuleFor(dto => dto.BankAccountId)
.NotEmpty();
}
}
Expand All @@ -54,22 +54,20 @@ public class BankAccountModifyBodyDtoValidator : AbstractValidator<BankAccountMo
{
public BankAccountModifyBodyDtoValidator()
{
RuleFor(c => c.Iban)
.Cascade(CascadeMode.Stop)
_ = RuleFor(c => c.Iban)
.NotEmpty()
.Iban();

RuleFor(c => c.Bic)
.Cascade(CascadeMode.Stop)
_ = RuleFor(c => c.Bic)
.NotEmpty()
.When(dto => !dto.Iban.StartsWith("de", StringComparison.InvariantCultureIgnoreCase), ApplyConditionTo.CurrentValidator)
.Bic()
.When(dto => !string.IsNullOrWhiteSpace(dto.Bic), ApplyConditionTo.CurrentValidator);

RuleFor(c => c.CommentInner)
_ = RuleFor(c => c.CommentInner)
.RestrictedFreeText(500);

RuleFor(c => c.AccountOwner)
_ = RuleFor(c => c.AccountOwner)
.PersonName(50);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class ContactDetailCreateDtoMappingProfile : Profile
{
public ContactDetailCreateDtoMappingProfile()
{
CreateMap<ContactDetailCreateDto, Create.Command>()
_ = CreateMap<ContactDetailCreateDto, Create.Command>()
.ForMember(dest => dest.PersonId, opt => opt.MapFrom(src => src.Id))
.ForMember(dest => dest.Key, opt => opt.MapFrom(src => src.Body.Key))
.ForMember(dest => dest.Value, opt => opt.MapFrom(src => src.Body.Value))
Expand All @@ -39,38 +39,37 @@ public class ContactDetailCreateDtoValidator : IdFromRouteDtoValidator<ContactDe
{
public ContactDetailCreateDtoValidator()
{
RuleFor(d => d.Body)
_ = RuleFor(d => d.Body)
.SetValidator(new ContactDetailCreateBodyDtoValidator());
}
}
public class ContactDetailCreateBodyDtoValidator : AbstractValidator<ContactDetailCreateBodyDto>
{
public ContactDetailCreateBodyDtoValidator()
{
RuleFor(c => c.Key)
.Cascade(CascadeMode.Stop)
_ = RuleFor(c => c.Key)
.NotEmpty()
.IsInEnum();

RuleFor(c => c.Value)
_ = RuleFor(c => c.Value)
.NotEmpty();

RuleFor(c => c.Value)
_ = RuleFor(c => c.Value)
.ValidUri(1000)
.When(dto => ContactDetailKey.Url.Equals(dto?.Key));

RuleFor(c => c.Value)
_ = RuleFor(c => c.Value)
.EmailAddress()
.When(dto => ContactDetailKey.EMail.Equals(dto?.Key));

RuleFor(c => c.Value)
_ = RuleFor(c => c.Value)
.PhoneNumber()
.When(dto => ContactDetailKey.PhoneNumber.Equals(dto?.Key));

RuleFor(c => c.CommentTeam)
_ = RuleFor(c => c.CommentTeam)
.RestrictedFreeText(500);

RuleFor(c => c.Preference)
_ = RuleFor(c => c.Preference)
.FiveStarRating();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class ContactDetailModifyDtoMappingProfile : Profile
{
public ContactDetailModifyDtoMappingProfile()
{
CreateMap<ContactDetailModifyDto, Modify.Command>()
_ = CreateMap<ContactDetailModifyDto, Modify.Command>()
.ForMember(dest => dest.PersonId, opt => opt.MapFrom(src => src.Id))
.ForMember(dest => dest.Id, opt => opt.MapFrom(src => src.ContactDetailId))
.ForMember(dest => dest.Key, opt => opt.MapFrom(src => src.Body.Key))
Expand All @@ -43,10 +43,10 @@ public class ContactDetailModifyDtoValidator : IdFromRouteDtoValidator<ContactDe
{
public ContactDetailModifyDtoValidator()
{
RuleFor(d => d.Body)
_ = RuleFor(d => d.Body)
.SetValidator(new ContactDetailModifyBodyDtoValidator());

RuleFor(dto => dto.ContactDetailId)
_ = RuleFor(dto => dto.ContactDetailId)
.NotEmpty();
}
}
Expand All @@ -55,30 +55,29 @@ public class ContactDetailModifyBodyDtoValidator : AbstractValidator<ContactDeta
{
public ContactDetailModifyBodyDtoValidator()
{
RuleFor(c => c.Key)
.Cascade(CascadeMode.Stop)
_ = RuleFor(c => c.Key)
.NotEmpty()
.IsInEnum();

RuleFor(c => c.Value)
_ = RuleFor(c => c.Value)
.NotEmpty();

RuleFor(c => c.Value)
_ = RuleFor(c => c.Value)
.ValidUri(1000)
.When(dto => ContactDetailKey.Url.Equals(dto?.Key));

RuleFor(c => c.Value)
_ = RuleFor(c => c.Value)
.EmailAddress()
.When(dto => ContactDetailKey.EMail.Equals(dto?.Key));

RuleFor(c => c.Value)
_ = RuleFor(c => c.Value)
.PhoneNumber()
.When(dto => ContactDetailKey.PhoneNumber.Equals(dto?.Key));

RuleFor(c => c.CommentTeam)
_ = RuleFor(c => c.CommentTeam)
.RestrictedFreeText(500);

RuleFor(c => c.Preference)
_ = RuleFor(c => c.Preference)
.FiveStarRating();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,38 +20,37 @@ public class MyContactDetailCreateDtoMappingProfile : Profile
{
public MyContactDetailCreateDtoMappingProfile()
{
CreateMap<MyContactDetailCreateDto, Create.Command>();
_ = CreateMap<MyContactDetailCreateDto, Create.Command>();
}
}

public class MyContactDetailCreateDtoValidator : AbstractValidator<MyContactDetailCreateDto>
{
public MyContactDetailCreateDtoValidator()
{
RuleFor(c => c.Key)
.Cascade(CascadeMode.Stop)
_ = RuleFor(c => c.Key)
.NotEmpty()
.IsInEnum();

RuleFor(c => c.Value)
_ = RuleFor(c => c.Value)
.NotEmpty();

RuleFor(c => c.Value)
_ = RuleFor(c => c.Value)
.ValidUri(1000)
.When(dto => ContactDetailKey.Url.Equals(dto?.Key));

RuleFor(c => c.Value)
_ = RuleFor(c => c.Value)
.EmailAddress()
.When(dto => ContactDetailKey.EMail.Equals(dto?.Key));

RuleFor(c => c.Value)
_ = RuleFor(c => c.Value)
.PhoneNumber()
.When(dto => ContactDetailKey.PhoneNumber.Equals(dto?.Key));

RuleFor(c => c.CommentInner)
_ = RuleFor(c => c.CommentInner)
.RestrictedFreeText(500);

RuleFor(c => c.Preference)
_ = RuleFor(c => c.Preference)
.FiveStarRating();
}
}
Expand Down
Loading

0 comments on commit d944a44

Please sign in to comment.