Add project data
This commit is contained in:
26
Tabletop.Core/Validators/AbilityValidator.cs
Normal file
26
Tabletop.Core/Validators/AbilityValidator.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using FluentValidation;
|
||||
using System.Globalization;
|
||||
using Tabletop.Core.Models;
|
||||
|
||||
namespace Tabletop.Core.Validators
|
||||
{
|
||||
public class AbilityValidator : AbstractValidator<Ability>
|
||||
{
|
||||
public AbilityValidator()
|
||||
{
|
||||
RuleFor(x => x.GetLocalization(CultureInfo.CurrentCulture).Name)
|
||||
.NotEmpty()
|
||||
.WithMessage("The field must be filled")
|
||||
.MaximumLength(50)
|
||||
.WithMessage("Name must contain only 50 characters.");
|
||||
|
||||
RuleFor(x => x.GetLocalization(CultureInfo.CurrentCulture).Description)
|
||||
.MaximumLength(1000)
|
||||
.WithMessage("Description must contain only 1000 characters.");
|
||||
|
||||
RuleFor(x => x.GetLocalization(CultureInfo.CurrentCulture).Mechanic)
|
||||
.MaximumLength(1000)
|
||||
.WithMessage("Mechanic must contain only 1000 characters.");
|
||||
}
|
||||
}
|
||||
}
|
||||
28
Tabletop.Core/Validators/FractionValidator.cs
Normal file
28
Tabletop.Core/Validators/FractionValidator.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using FluentValidation;
|
||||
using System.Globalization;
|
||||
using Tabletop.Core.Models;
|
||||
|
||||
namespace Tabletop.Core.Validators
|
||||
{
|
||||
public class FractionValidator : AbstractValidator<Fraction>
|
||||
{
|
||||
public FractionValidator()
|
||||
{
|
||||
RuleFor(x => x.GetLocalization(CultureInfo.CurrentCulture).Name)
|
||||
.NotEmpty()
|
||||
.WithMessage("The field must be filled")
|
||||
.MaximumLength(50)
|
||||
.WithMessage("Name must contain only 50 characters.");
|
||||
|
||||
RuleFor(x => x.GetLocalization(CultureInfo.CurrentCulture).ShortName)
|
||||
.NotEmpty()
|
||||
.WithMessage("The field must be filled")
|
||||
.MaximumLength(3)
|
||||
.WithMessage("Name must contain only 3 characters.");
|
||||
|
||||
RuleFor(x => x.GetLocalization(CultureInfo.CurrentCulture).Description)
|
||||
.MaximumLength(1000)
|
||||
.WithMessage("Description must contain only 1000 characters.");
|
||||
}
|
||||
}
|
||||
}
|
||||
32
Tabletop.Core/Validators/GameValidator.cs
Normal file
32
Tabletop.Core/Validators/GameValidator.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using FluentValidation;
|
||||
using Tabletop.Core.Models;
|
||||
|
||||
namespace Tabletop.Core.Validators
|
||||
{
|
||||
public class GameValidator : AbstractValidator<Game>
|
||||
{
|
||||
public GameValidator()
|
||||
{
|
||||
RuleFor(x => x.Name)
|
||||
.NotEmpty()
|
||||
.WithMessage("The field must be filled")
|
||||
.MaximumLength(30)
|
||||
.WithMessage("Name must contain only 30 characters.");
|
||||
|
||||
RuleFor(x => x.GamemodeId)
|
||||
.NotEmpty()
|
||||
.WithMessage("Game Mode must be selected");
|
||||
|
||||
When(x => x.GamemodeId is 1 or 4, () =>
|
||||
{
|
||||
RuleFor(x => x.NumberOfRounds)
|
||||
.NotNull()
|
||||
.WithMessage("Rounds must be selected");
|
||||
});
|
||||
|
||||
RuleFor(x => x.Force)
|
||||
.NotEmpty()
|
||||
.WithMessage("Force must be selected");
|
||||
}
|
||||
}
|
||||
}
|
||||
26
Tabletop.Core/Validators/GamemodeValidator.cs
Normal file
26
Tabletop.Core/Validators/GamemodeValidator.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using FluentValidation;
|
||||
using System.Globalization;
|
||||
using Tabletop.Core.Models;
|
||||
|
||||
namespace Tabletop.Core.Validators
|
||||
{
|
||||
public class GamemodeValidator : AbstractValidator<Gamemode>
|
||||
{
|
||||
public GamemodeValidator()
|
||||
{
|
||||
RuleFor(x => x.GetLocalization(CultureInfo.CurrentCulture).Name)
|
||||
.NotEmpty()
|
||||
.WithMessage("The field must be filled")
|
||||
.MaximumLength(50)
|
||||
.WithMessage("Name must contain only 50 characters.");
|
||||
|
||||
RuleFor(x => x.GetLocalization(CultureInfo.CurrentCulture).Description)
|
||||
.MaximumLength(1000)
|
||||
.WithMessage("Description must contain only 1000 characters.");
|
||||
|
||||
RuleFor(x => x.GetLocalization(CultureInfo.CurrentCulture).Mechanic)
|
||||
.MaximumLength(1000)
|
||||
.WithMessage("Description must contain only 1000 characters.");
|
||||
}
|
||||
}
|
||||
}
|
||||
19
Tabletop.Core/Validators/PlayerValidator.cs
Normal file
19
Tabletop.Core/Validators/PlayerValidator.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using FluentValidation;
|
||||
using Tabletop.Core.Models;
|
||||
|
||||
namespace Tabletop.Core.Validators
|
||||
{
|
||||
public class PlayerValidator : AbstractValidator<Player>
|
||||
{
|
||||
public PlayerValidator()
|
||||
{
|
||||
RuleFor(x => x.UsedForce)
|
||||
.LessThanOrEqualTo(x => x.AllowedForce)
|
||||
.WithMessage("Force points over limit");
|
||||
|
||||
RuleFor(x => x.Units)
|
||||
.NotEmpty()
|
||||
.WithMessage("At least one unit must be selected");
|
||||
}
|
||||
}
|
||||
}
|
||||
29
Tabletop.Core/Validators/TemplateValidator.cs
Normal file
29
Tabletop.Core/Validators/TemplateValidator.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using FluentValidation;
|
||||
using Tabletop.Core.Models;
|
||||
|
||||
namespace Tabletop.Core.Validators
|
||||
{
|
||||
public class TemplateValidator : AbstractValidator<Template>
|
||||
{
|
||||
public TemplateValidator()
|
||||
{
|
||||
RuleFor(x => x.Name)
|
||||
.NotEmpty()
|
||||
.WithMessage("The field must be filled")
|
||||
.MaximumLength(50)
|
||||
.WithMessage("Name must contain only 50 characters.");
|
||||
|
||||
RuleFor(x => x.FractionId)
|
||||
.NotEmpty()
|
||||
.WithMessage("Faction must be selected");
|
||||
|
||||
RuleFor(x => x.Force)
|
||||
.NotEmpty()
|
||||
.WithMessage("Force must be selected");
|
||||
|
||||
RuleFor(x => x.UsedForce)
|
||||
.LessThanOrEqualTo(x => x.Force)
|
||||
.WithMessage("Force points over limit");
|
||||
}
|
||||
}
|
||||
}
|
||||
42
Tabletop.Core/Validators/UnitValidator.cs
Normal file
42
Tabletop.Core/Validators/UnitValidator.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
using FluentValidation;
|
||||
using System.Globalization;
|
||||
using Tabletop.Core.Models;
|
||||
|
||||
namespace Tabletop.Core.Validators
|
||||
{
|
||||
public class UnitValidator : AbstractValidator<Unit>
|
||||
{
|
||||
public UnitValidator()
|
||||
{
|
||||
RuleFor(x => x.GetLocalization(CultureInfo.CurrentCulture).Name)
|
||||
.NotEmpty()
|
||||
.WithMessage("The field must be filled")
|
||||
.MaximumLength(50)
|
||||
.WithMessage("Name must contain only 50 characters.");
|
||||
|
||||
RuleFor(x => x.FractionId)
|
||||
.NotEmpty()
|
||||
.WithMessage("Faction must be selected");
|
||||
|
||||
RuleFor(x => x.GetLocalization(CultureInfo.CurrentCulture).Description)
|
||||
.MaximumLength(500)
|
||||
.WithMessage("Description must contain only 500 characters.");
|
||||
|
||||
RuleFor(x => x.GetLocalization(CultureInfo.CurrentCulture).Mechanic)
|
||||
.MaximumLength(500)
|
||||
.WithMessage("Description must contain only 500 characters.");
|
||||
|
||||
RuleFor(x => x.Defense)
|
||||
.NotEmpty()
|
||||
.WithMessage("Defense must be filled.");
|
||||
|
||||
RuleFor(x => x.Moving)
|
||||
.NotEmpty()
|
||||
.WithMessage("The field must be filled")
|
||||
.LessThan(30)
|
||||
.WithMessage("The field may be a maximum of 30")
|
||||
.GreaterThan(0)
|
||||
.WithMessage("The field must not be greater than 0");
|
||||
}
|
||||
}
|
||||
}
|
||||
38
Tabletop.Core/Validators/WeaponValidator.cs
Normal file
38
Tabletop.Core/Validators/WeaponValidator.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using FluentValidation;
|
||||
using System.Globalization;
|
||||
using Tabletop.Core.Models;
|
||||
|
||||
namespace Tabletop.Core.Validators
|
||||
{
|
||||
public class WeaponValidator : AbstractValidator<Weapon>
|
||||
{
|
||||
public WeaponValidator()
|
||||
{
|
||||
RuleFor(x => x.GetLocalization(CultureInfo.CurrentCulture).Name)
|
||||
.NotEmpty()
|
||||
.WithMessage("The field must be filled")
|
||||
.MaximumLength(50)
|
||||
.WithMessage("Name must contain only 50 characters.");
|
||||
|
||||
RuleFor(x => x.GetLocalization(CultureInfo.CurrentCulture).Description)
|
||||
.MaximumLength(500)
|
||||
.WithMessage("Description must contain only 500 characters.");
|
||||
|
||||
RuleFor(x => x.Attack)
|
||||
.NotEmpty()
|
||||
.WithMessage("Attack must be filled.");
|
||||
|
||||
RuleFor(x => x.Quality)
|
||||
.NotEmpty()
|
||||
.WithMessage("Quality must be filled");
|
||||
|
||||
RuleFor(x => x.Range)
|
||||
.NotEmpty()
|
||||
.WithMessage("Range must be filled");
|
||||
|
||||
RuleFor(x => x.Dices)
|
||||
.NotEmpty()
|
||||
.WithMessage("Dices must be filled");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user