Before changing Piece[,] to Dictionary<string,Piece>
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
using FluentValidation;
|
||||
using Gameboard.ShogiUI.Sockets.ServiceModels.Socket.Messages;
|
||||
using Gameboard.ShogiUI.Sockets.ServiceModels.Socket.Types;
|
||||
|
||||
namespace Gameboard.ShogiUI.Sockets.Services.RequestValidators
|
||||
{
|
||||
public class CreateGameRequestValidator : AbstractValidator<CreateGameRequest>
|
||||
{
|
||||
public CreateGameRequestValidator()
|
||||
{
|
||||
RuleFor(_ => _.Action).Equal(ClientAction.CreateGame);
|
||||
RuleFor(_ => _.GameName).NotEmpty();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using FluentValidation;
|
||||
using Gameboard.ShogiUI.Sockets.ServiceModels.Socket.Messages;
|
||||
using Gameboard.ShogiUI.Sockets.ServiceModels.Socket.Types;
|
||||
|
||||
namespace Gameboard.ShogiUI.Sockets.Services.RequestValidators
|
||||
{
|
||||
public class JoinByCodeRequestValidator : AbstractValidator<JoinByCodeRequest>
|
||||
{
|
||||
public JoinByCodeRequestValidator()
|
||||
{
|
||||
RuleFor(_ => _.Action).Equal(ClientAction.JoinByCode);
|
||||
RuleFor(_ => _.JoinCode).NotEmpty();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using FluentValidation;
|
||||
using Gameboard.ShogiUI.Sockets.ServiceModels.Socket.Messages;
|
||||
using Gameboard.ShogiUI.Sockets.ServiceModels.Socket.Types;
|
||||
|
||||
namespace Gameboard.ShogiUI.Sockets.Services.RequestValidators
|
||||
{
|
||||
public class JoinGameRequestValidator : AbstractValidator<JoinGameRequest>
|
||||
{
|
||||
public JoinGameRequestValidator()
|
||||
{
|
||||
RuleFor(_ => _.Action).Equal(ClientAction.JoinGame);
|
||||
RuleFor(_ => _.GameName).NotEmpty();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using FluentValidation;
|
||||
using Gameboard.ShogiUI.Sockets.ServiceModels.Socket.Messages;
|
||||
using Gameboard.ShogiUI.Sockets.ServiceModels.Socket.Types;
|
||||
|
||||
namespace Gameboard.ShogiUI.Sockets.Services.RequestValidators
|
||||
{
|
||||
public class ListGamesRequestValidator : AbstractValidator<ListGamesRequest>
|
||||
{
|
||||
public ListGamesRequestValidator()
|
||||
{
|
||||
RuleFor(_ => _.Action).Equal(ClientAction.ListGames);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using FluentValidation;
|
||||
using Gameboard.ShogiUI.Sockets.ServiceModels.Socket.Messages;
|
||||
using Gameboard.ShogiUI.Sockets.ServiceModels.Socket.Types;
|
||||
|
||||
namespace Gameboard.ShogiUI.Sockets.Services.RequestValidators
|
||||
{
|
||||
public class LoadGameRequestValidator : AbstractValidator<LoadGameRequest>
|
||||
{
|
||||
public LoadGameRequestValidator()
|
||||
{
|
||||
RuleFor(_ => _.Action).Equal(ClientAction.LoadGame);
|
||||
RuleFor(_ => _.GameName).NotEmpty();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
using FluentValidation;
|
||||
using Gameboard.ShogiUI.Sockets.ServiceModels.Socket.Messages;
|
||||
using Gameboard.ShogiUI.Sockets.ServiceModels.Socket.Types;
|
||||
|
||||
namespace Gameboard.ShogiUI.Sockets.Services.RequestValidators
|
||||
{
|
||||
public class MoveRequestValidator : AbstractValidator<MoveRequest>
|
||||
{
|
||||
public MoveRequestValidator()
|
||||
{
|
||||
RuleFor(_ => _.Action).Equal(ClientAction.Move);
|
||||
RuleFor(_ => _.GameName).NotEmpty();
|
||||
RuleFor(_ => _.Move.From)
|
||||
.Null()
|
||||
.When(_ => _.Move.PieceFromCaptured.HasValue)
|
||||
.WithMessage("Move.From and Move.PieceFromCaptured are mutually exclusive properties.");
|
||||
RuleFor(_ => _.Move.From)
|
||||
.NotEmpty()
|
||||
.When(_ => !_.Move.PieceFromCaptured.HasValue)
|
||||
.WithMessage("Move.From and Move.PieceFromCaptured are mutually exclusive properties.");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user