Skip to content

Feature: Support FluentValidation warning/info severity in Blazor forms #76

@pianomanjh

Description

@pianomanjh

Problem

FluentValidation supports a Severity property on validation rules (Error, Warning, Info), but Blazilla currently treats all ValidationFailure results as errors — they all go into the ValidationMessageStore, which means:

  1. Warning-severity rules block form submission (because EditContext.Validate() checks GetValidationMessages())
  2. No way to display warnings differently from errors (e.g. amber vs red styling)
  3. No way to show advisory messages that inform the user without preventing submission

This is a common need in business applications where some fields are "recommended but not required" — for example, showing "Description is recommended" as a warning while still allowing the form to submit.

Proposed Solution

Route non-error severity failures to an EditContext.Properties side-channel instead of the ValidationMessageStore. This is a non-breaking change — existing error behavior is completely untouched.

The core idea:

  • In ApplyValidationResults, check validationFailure.Severity — only add Severity.Error failures to the ValidationMessageStore
  • Store warning/info failures in EditContext.Properties via a small static helper class
  • Provide extension methods on EditContext to retrieve warnings (GetWarnings, GetAllWarnings, HasWarnings)
  • Optionally provide a WarningValidationMessage<TValue> component analogous to ValidationMessage<TValue> that reads from the warnings side-channel

I've successfully implemented this approach in a fork of the Blazored.FluentValidation library (v2.2.0) and have been using it in production. The changes are well-contained and the approach works reliably with both sync and async validation, field-level and model-level validation, and mixed error/warning rule sets.

Happy to submit a PR if there's interest.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions