Table of Contents

Class ValidationArgsProjection

Namespace
Trellis.FluentValidation
Assembly
Trellis.FluentValidation.dll

Projects a FluentValidation.Results.ValidationFailure's placeholder values onto the structured Args a client can use to render its own localized message.

public static class ValidationArgsProjection
Inheritance
ValidationArgsProjection
Inherited Members

Remarks

Blanket pass-through is unsafe on two independent counts, so two controls apply.

Correctness. FluentValidation populates placeholders its message never uses, and it populates them with sentinels: a MinimumLength(50) failure carries MaxLength = -1, and a MaximumLength(2) failure carries MinLength = 0. A client rendering "must be between 50 and -1 characters" from those is a real bug, so the allowlist is per validator.

Disclosure. An arg can carry submitted input — comparisonValue does whenever the rule compares against another property — and no structural rule distinguishes the safe case from the unsafe one, because FluentValidation reports ComparisonProperty only for a simple member expression. So the control is not a discriminator but the containment gate in ShouldEmit(string, string, string, string, bool).

Methods

Project(ValidationFailure, ValidationArgsOptions?)

Builds the args for a failure, or null when none survive.

public static ImmutableDictionary<string, ValidationArgValue>? Project(ValidationFailure failure, ValidationArgsOptions? options = null)

Parameters

failure ValidationFailure

The FluentValidation failure to project.

options ValidationArgsOptions

The application's widening of the default allowlist, or null to apply the framework default alone.

Returns

ImmutableDictionary<string, ValidationArgValue>