mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 15:11:10 +00:00
Replaces FluentValidation with the custom validation framework in the web project
This commit is contained in:
1 parent
587daaabb7
commit
57e8e2ed65
19 files changed
+1020
-104
No files matched your search
@@ -0,0 +1,49 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Presentation.Web.Common.Primitives;
|
||||
using System;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Common.Validation;
|
||||
|
||||
/// <summary>
|
||||
/// Provides a fluent API for building validation rules for a specific type.
|
||||
/// </summary>
|
||||
/// <typeparam name="TRequest">The type of the instance being validated.</typeparam>
|
||||
/// <typeparam name="TProperty">The type of the specific property on the instance that the rule applies to.</typeparam>
|
||||
public interface IRuleBuilder<TRequest, TProperty>
|
||||
{
|
||||
/// <summary>
|
||||
/// Specifies a condition that the property must satisfy to be considered valid.
|
||||
/// </summary>
|
||||
/// <param name="predicate">A function to test the property value.</param>
|
||||
/// <returns>The current <see cref="IRuleBuilder{TRequest, TProperty}"/> instance for method chaining.</returns>
|
||||
IRuleBuilder<TRequest, TProperty> Must(Func<TProperty, bool> predicate);
|
||||
|
||||
/// <summary>
|
||||
/// Specifies a condition that both the request instance and the property value must satisfy to be considered valid.
|
||||
/// </summary>
|
||||
/// <param name="predicate">A function to test the request instance together with the property value.</param>
|
||||
/// <returns>The current <see cref="IRuleBuilder{TRequest, TProperty}"/> instance for method chaining.</returns>
|
||||
IRuleBuilder<TRequest, TProperty> Must(Func<TRequest, TProperty, bool> predicate);
|
||||
|
||||
/// <summary>
|
||||
/// Specifies a condition that must be met for the validation rule to be executed.
|
||||
/// </summary>
|
||||
/// <param name="condition">A function evaluating the request instance.</param>
|
||||
/// <returns>The current <see cref="IRuleBuilder{TRequest, TProperty}"/> instance for method chaining.</returns>
|
||||
IRuleBuilder<TRequest, TProperty> When(Func<TRequest, bool> condition);
|
||||
|
||||
/// <summary>
|
||||
/// Specifies a custom <see cref="Error"/> object to be returned when the validation fails.
|
||||
/// </summary>
|
||||
/// <param name="error">The specific error to return upon failure.</param>
|
||||
/// <returns>The current <see cref="IRuleBuilder{TRequest, TProperty}"/> instance for method chaining.</returns>
|
||||
IRuleBuilder<TRequest, TProperty> WithError(Error error);
|
||||
|
||||
/// <summary>
|
||||
/// Defines nested validation rules for the complex property being validated.
|
||||
/// </summary>
|
||||
/// <param name="configure">An action used to configure the inline validator for the property.</param>
|
||||
/// <returns>The current <see cref="IRuleBuilder{TRequest, TProperty}"/> instance for method chaining.</returns>
|
||||
IRuleBuilder<TRequest, TProperty> ChildRules(Action<AbstractValidator<TProperty>> configure);
|
||||
}
|
||||
Reference in new issue
Block a user