OrionGuard.Blazor 7.0.0

dotnet add package OrionGuard.Blazor --version 7.0.0
                    
NuGet\Install-Package OrionGuard.Blazor -Version 7.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="OrionGuard.Blazor" Version="7.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="OrionGuard.Blazor" Version="7.0.0" />
                    
Directory.Packages.props
<PackageReference Include="OrionGuard.Blazor" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add OrionGuard.Blazor --version 7.0.0
                    
#r "nuget: OrionGuard.Blazor, 7.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package OrionGuard.Blazor@7.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=OrionGuard.Blazor&version=7.0.0
                    
Install as a Cake Addin
#tool nuget:?package=OrionGuard.Blazor&version=7.0.0
                    
Install as a Cake Tool

OrionGuard.Blazor

Runs your OrionGuard rules inside an EditForm, so the same validator the API uses also drives the form's field messages.

dotnet add package OrionGuard.Blazor
@using Moongazing.OrionGuard.Blazor

<EditForm Model="model" OnValidSubmit="Save">
    <OrionGuardFluentValidator TModel="SignUpModel" />

    <InputText @bind-Value="model.Email" />
    <ValidationMessage For="() => model.Email" />

    <button type="submit">Save</button>
</EditForm>

@code {
    private readonly SignUpModel model = new();

    private void Save() { }
}

Typing an invalid address and leaving the field puts the validator's message under that input; submitting with it invalid never calls Save. The core OrionGuard package comes along as a dependency.

The component resolves IValidator<SignUpModel> from DI, so register it:

using Microsoft.Extensions.DependencyInjection;
using Moongazing.OrionGuard.Blazor.Extensions;
using Moongazing.OrionGuard.DependencyInjection;

public sealed class SignUpModel
{
    public string Email { get; set; } = "";
}

public sealed class SignUpModelValidator : AbstractValidator<SignUpModel>
{
    public SignUpModelValidator()
    {
        RuleFor(x => x.Email, nameof(SignUpModel.Email), p => p.NotEmpty().Email());
    }
}

public static class BlazorSetup
{
    public static void Add(IServiceCollection services) =>
        services
            .AddOrionGuardBlazor()
            .AddValidator<SignUpModel, SignUpModelValidator>();
}

AddOrionGuardBlazor() only calls AddOrionGuard(); it registers no validators.

The two components

<OrionGuardFluentValidator TModel="..." /> injects IValidator<TModel> and runs it. A validator for the model type must be registered, or the component cannot be constructed.

<OrionGuardValidator /> needs no registration at all: it validates EditContext.Model with AttributeValidator, using the attributes from Moongazing.OrionGuard.Attributes — [NotNull], [NotEmpty], [Length], [Email], [Range], [Regex], [Positive].

Both react to the same EditContext events: on submit the messages are cleared and the whole model is validated; when one field changes the whole model is validated again but only that field's errors are shown. An error is attached to FieldIdentifier(model, error.ParameterName).

What this does not do

  • No async rules in the form. OrionGuardFluentValidator calls the synchronous Validate(model), so RuleForAsync rules never run here. That is forced by Blazor: EditContext.Validate() raises its events synchronously and returns a verdict immediately, so an async rule could not finish in time. For a "is this email taken" check, inject IValidator<TModel> into the page and await ValidateAsync(...) in the submit handler.
  • <OrionGuardValidator /> ignores System.ComponentModel.DataAnnotations. [Required] and friends are not read; add <DataAnnotationsValidator /> alongside it if your model uses both.
  • The error's ParameterName must equal the property name for <ValidationMessage For="..." /> to find it. An error for a nested object does not map to a field — it still shows in <ValidationSummary />, just not next to an input.
  • Both components require a cascading EditContext. Outside an EditForm they throw InvalidOperationException.
  • Server-hosted Blazor only. The package references the Microsoft.AspNetCore.App shared framework, which a Blazor WebAssembly client project cannot reference. Use it from Blazor Server or interactive server rendering.

Targets

net8.0, net9.0, net10.0. A Razor class library on the ASP.NET Core shared framework.

With the rest of OrionGuard

OrionGuard · OrionGuard.AspNetCore (the same validator behind the API the form posts to)

Documentation

License

MIT. See LICENSE.txt.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
7.0.0 83 9/20/2026
6.7.0 125 7/20/2026
6.6.2 133 6/20/2026
6.6.1 121 6/20/2026
6.6.0 120 6/19/2026
6.5.30 132 6/17/2026
6.5.29 118 6/15/2026
6.5.28 121 6/15/2026
6.5.27 115 6/15/2026
6.5.26 120 6/13/2026
6.5.25 112 6/13/2026
6.5.24 117 6/12/2026
6.5.23 123 6/12/2026
6.5.22 119 6/11/2026
6.5.21 118 6/11/2026
6.5.20 117 6/11/2026
6.5.19 119 6/11/2026
6.5.18 116 6/11/2026
6.5.16 114 6/11/2026
6.5.15 119 6/11/2026
Loading failed