-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #51 from Tynab/develop
231120
- Loading branch information
Showing
8 changed files
with
61 additions
and
42 deletions.
There are no files selected for viewing
4 changes: 2 additions & 2 deletions
4
...ontracts/Requests/DeveloperTypeRequest.cs → ...veloperType/DeveloperTypeCreateRequest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
src/YANLib.Application.Contracts/Requests/DeveloperType/DeveloperTypeUpdateRequest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
namespace YANLib.Requests.DeveloperType; | ||
|
||
public sealed class DeveloperTypeUpdateRequest | ||
{ | ||
public string Name { get; set; } | ||
|
||
public bool? IsActive { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 8 additions & 8 deletions
16
src/YANLib.Application/Validations/DeveloperTypeValidation.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,35 @@ | ||
using FluentValidation; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using YANLib.Requests; | ||
using YANLib.Requests.DeveloperType; | ||
using static YANLib.YANLibDomainErrorCodes; | ||
|
||
namespace YANLib.Validations; | ||
|
||
public sealed class DeveloperTypeValidator : AbstractValidator<DeveloperTypeRequest> | ||
public sealed class DeveloperTypeCreateValidator : AbstractValidator<DeveloperTypeCreateRequest> | ||
{ | ||
public DeveloperTypeValidator() | ||
public DeveloperTypeCreateValidator() | ||
{ | ||
_ = RuleFor(x => x.Code).NotNull().NotEmpty().GreaterThanOrEqualTo(0).WithErrorCode(BAD_REQUEST_ID).WithMessage(YANLibDomainErrorMessages.BAD_REQUEST_ID); | ||
_ = RuleFor(x => x.Name).NotNull().NotEmpty().WithErrorCode(BAD_REQUEST_NAME).WithMessage(YANLibDomainErrorMessages.BAD_REQUEST_NAME); | ||
} | ||
} | ||
|
||
public sealed class DeveloperTypeValidators : AbstractValidator<List<DeveloperTypeRequest>> | ||
public sealed class DeveloperTypeCreateValidators : AbstractValidator<List<DeveloperTypeCreateRequest>> | ||
{ | ||
#region Constructors | ||
public DeveloperTypeValidators() | ||
public DeveloperTypeCreateValidators() | ||
{ | ||
_ = RuleFor(x => x).NotNull().NotEmpty().WithErrorCode(BAD_REQUEST).WithMessage(YANLibDomainErrorMessages.BAD_REQUEST); | ||
_ = RuleForEach(s => s).SetValidator(new DeveloperTypeValidator()); | ||
_ = RuleForEach(s => s).SetValidator(new DeveloperTypeCreateValidator()); | ||
_ = RuleFor(x => x).Must(IsNotEmptyAndNull).WithErrorCode(BAD_REQUEST).WithMessage(YANLibDomainErrorMessages.BAD_REQUEST); | ||
_ = RuleFor(x => x).Must(NameIsNotWhiteSpace).WithErrorCode(BAD_REQUEST_NAME).WithMessage(YANLibDomainErrorMessages.BAD_REQUEST_NAME); | ||
} | ||
#endregion | ||
|
||
#region Methods | ||
private bool IsNotEmptyAndNull(List<DeveloperTypeRequest> requests) => requests.IsNotEmptyAndNull(); | ||
private bool IsNotEmptyAndNull(List<DeveloperTypeCreateRequest> requests) => requests.IsNotEmptyAndNull(); | ||
|
||
private bool NameIsNotWhiteSpace(List<DeveloperTypeRequest> requests) => requests.Select(x => x.Name).AllNotWhiteSpaceAndNull(); | ||
private bool NameIsNotWhiteSpace(List<DeveloperTypeCreateRequest> requests) => requests.Select(x => x.Name).AllNotWhiteSpaceAndNull(); | ||
#endregion | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters