Table of Contents

Class MudFormValidatorBase<T>

Namespace
NuvTools.AspNetCore.Blazor.MudBlazor.Validators
Assembly
NuvTools.AspNetCore.Blazor.MudBlazor.dll

Base abstract validator that provides property-level validation support using FluentValidation, specifically designed for MudBlazor MudForm integration.

public abstract class MudFormValidatorBase<T> : AbstractValidator<T>, IValidator<T>, IValidator, IEnumerable<IValidationRule>, IEnumerable

Type Parameters

T

The type of the model being validated.

Inheritance
AbstractValidator<T>
MudFormValidatorBase<T>
Implements
IValidator<T>
IValidator
IEnumerable<IValidationRule>
Inherited Members
AbstractValidator<T>.Validate(T)
AbstractValidator<T>.Validate(ValidationContext<T>)
AbstractValidator<T>.CreateDescriptor()
AbstractValidator<T>.Include(IValidator<T>)
AbstractValidator<T>.GetEnumerator()
AbstractValidator<T>.PreValidate(ValidationContext<T>, ValidationResult)
AbstractValidator<T>.RaiseValidationException(ValidationContext<T>, ValidationResult)
AbstractValidator<T>.OnRuleAdded(IValidationRule<T>)
AbstractValidator<T>.ClassLevelCascadeMode
AbstractValidator<T>.RuleLevelCascadeMode

Examples

public class MyModelValidator : MudFormValidatorBase<MyModel>
{
    public MyModelValidator()
    {
        RuleFor(x => x.Email).NotEmpty().EmailAddress();
    }
}

// In Blazor component:
<MudForm Model="@model" Validation="@(validator.ValidatePropertyAsync)">
    <MudTextField @bind-Value="model.Email" For="@(() => model.Email)" />
</MudForm>

Remarks

MudBlazor's MudForm component expects a validation delegate with the signature Func<object, string, Task<IEnumerable<string>>>. This base class exposes the ValidatePropertyAsync property that matches this signature, enabling seamless integration with MudForm's Validation parameter.

Properties

ValidatePropertyAsync

Gets a delegate that validates a single property asynchronously. This delegate is designed to be passed directly to MudBlazor's MudForm Validation parameter.

public Func<object, string, Task<IEnumerable<string>>> ValidatePropertyAsync { get; }

Property Value

Func<object, string, Task<IEnumerable<string>>>

A delegate that takes a model instance and a property name, and returns a task containing a sequence of validation error messages. Returns an empty collection when the property is valid.

Remarks

MudForm calls this delegate automatically for each field during validation. Only the specified property will be evaluated by FluentValidation.