feat: create request projects for basic CQRS

This commit is contained in:
Louis Seubert 2026-05-08 20:26:26 +02:00
commit d614788e06
Signed by: louis9902
GPG key ID: 4B9DB28F826553BD
190 changed files with 12236 additions and 0 deletions

View file

@ -0,0 +1,55 @@
// Copyright (c) The Geekeey Authors
// SPDX-License-Identifier: EUPL-1.2
namespace Geekeey.Request.Validation;
/// <summary>
/// Represents a builder for defining a validation rule for a specific property of a type.
/// </summary>
/// <typeparam name="T">The type of the object to be validated.</typeparam>
/// <typeparam name="TProperty">The type of the property to validate.</typeparam>
public interface IPropertyRuleBuilder<T, out TProperty>
{
/// <summary>
/// Defines a validation rule that must be met for the property to be considered valid.
/// </summary>
/// <param name="predicate">The predicate function that determines if the property value is valid.</param>
/// <param name="message">The error message to be returned if the validation fails.</param>
/// <returns>The current rule builder instance for method chaining.</returns>
IPropertyRuleBuilder<T, TProperty> Must(Func<TProperty, bool> predicate, string message);
/// <summary>
/// Sets the validator to be used for validating the property value.
/// </summary>
/// <param name="validator">The validator instance to use for validation.</param>
/// <returns>The current rule builder instance for method chaining.</returns>
IPropertyRuleBuilder<T, TProperty> SetValidator(IValidator validator);
/// <summary>
/// Sets the validator to be used for validating the property value.
/// </summary>
/// <typeparam name="TValidator">The type of the validator to use for validation.</typeparam>
/// <returns>The current rule builder instance for method chaining.</returns>
IPropertyRuleBuilder<T, TProperty> SetValidator<TValidator>() where TValidator : IValidator;
/// <summary>
/// Sets the error code for the validation rule.
/// </summary>
/// <param name="code">The error code to be associated with the validation rule.</param>
/// <returns>The current rule builder instance for method chaining.</returns>
IPropertyRuleBuilder<T, TProperty> WithCode(string code);
/// <summary>
/// Transforms the property path reported by the validation rule.
/// </summary>
/// <param name="transform">The function used to transform the rule property path.</param>
/// <returns>The current rule builder instance for method chaining.</returns>
IPropertyRuleBuilder<T, TProperty> WithPropertyPath(Func<PropertyPath, PropertyPath> transform);
/// <summary>
/// Sets the severity of the validation rule.
/// </summary>
/// <param name="severity">The severity level of the validation rule.</param>
/// <returns>The current rule builder instance for method chaining.</returns>
IPropertyRuleBuilder<T, TProperty> WithSeverity(Severity severity);
}