Replaces FluentValidation with the custom validation framework in the web project

This commit is contained in:
BinaryAlley committed 2026-08-19 10:25:28 -07:00
1 parent 587daaabb7
commit 57e8e2ed65
19 files changed
+1020 -104

No files matched your search

@@ -0,0 +1,28 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Presentation.Web.Common.DTO.Configuration;
using Lumina.Presentation.Web.Common.Primitives;
using Lumina.Presentation.Web.Common.Utilities;
using Lumina.Presentation.Web.Common.Validation;
using System;
using System.Buffers.Text;
#endregion
namespace Lumina.Presentation.Web.Common.Validators;
/// <summary>
/// Validates the needed validation rules for the EncryptionSettings application configuration settings section.
/// </summary>
public class EncryptionSettingsDtoValidator : AbstractValidator<EncryptionSettingsDto>
{
/// <summary>
/// Initializes a new instance of the <see cref="EncryptionSettingsDtoValidator"/> class.
/// </summary>
public EncryptionSettingsDtoValidator()
{
RuleFor(settings => settings.SecretKey)
.NotEmpty()
.WithError(Error.Validation(description: "Encryption secret key cannot be empty!"))
.Must(secretKey => Base64.IsValid(secretKey.AsSpan()))
.WithError(Error.Validation(description: "Encryption secret key must be a base64 string!"));
}
}
@@ -1,24 +0,0 @@
#region ========================================================================= USING =====================================================================================
using FluentValidation;
using Lumina.Presentation.Web.Common.DTO.Configuration;
using System;
using System.Buffers.Text;
#endregion
namespace Lumina.Presentation.Web.Common.Validators;
/// <summary>
/// Validates the needed validation rules for the EncryptionSettings application configuration settings section.
/// </summary>
public class EncryptionSettingsModelValidator : AbstractValidator<EncryptionSettingsDto>
{
/// <summary>
/// Initializes a new instance of the <see cref="EncryptionSettingsModelValidator"/> class.
/// </summary>
public EncryptionSettingsModelValidator()
{
RuleFor(x => x.SecretKey)
.NotEmpty().WithMessage("Encryption secret key cannot be empty!")
.Must(value => Base64.IsValid(value.AsSpan())).WithMessage("Encryption secret key must be a base64 string!");
}
}
@@ -0,0 +1,32 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Presentation.Web.Common.DTO.Configuration;
using Lumina.Presentation.Web.Common.Primitives;
using Lumina.Presentation.Web.Common.Utilities;
using Lumina.Presentation.Web.Common.Validation;
#endregion
namespace Lumina.Presentation.Web.Common.Validators;
/// <summary>
/// Validates the needed validation rules for the ServerConfiguration application configuration settings section.
/// </summary>
public class ServerConfigurationDtoValidator : AbstractValidator<ServerConfigurationDto>
{
/// <summary>
/// Initializes a new instance of the <see cref="ServerConfigurationDtoValidator"/> class.
/// </summary>
public ServerConfigurationDtoValidator()
{
RuleFor(configuration => configuration.BaseAddress)
.NotEmpty()
.WithError(Error.Validation(description: "Base address cannot be empty!"));
RuleFor(configuration => configuration.Port)
.InclusiveBetween((ushort)0, (ushort)65535)
.WithError(Error.Validation(description: "Port number must be between 0 and 65535!"));
RuleFor(configuration => configuration.ApiVersion)
.InclusiveBetween((char)0, (char)255)
.WithError(Error.Validation(description: "API version must be between 0 and 255!"));
}
}
@@ -1,22 +0,0 @@
#region ========================================================================= USING =====================================================================================
using FluentValidation;
using Lumina.Presentation.Web.Common.DTO.Configuration;
#endregion
namespace Lumina.Presentation.Web.Common.Validators;
/// <summary>
/// Validates the needed validation rules for the ServerConfiguration application configuration settings section.
/// </summary>
public class ServerConfigurationModelValidator : AbstractValidator<ServerConfigurationDto>
{
/// <summary>
/// Initializes a new instance of the <see cref="ServerConfigurationModelValidator"/> class.
/// </summary>
public ServerConfigurationModelValidator()
{
RuleFor(x => x.BaseAddress).NotEmpty().WithMessage("Base address cannot be empty!");
RuleFor(x => x.Port).InclusiveBetween((ushort)0, (ushort)65535).WithMessage("Port number must be between 0 and 65535!");
RuleFor(x => x.ApiVersion).InclusiveBetween((char)0, (char)255).WithMessage("API version must be between 0 and 255!");
}
}