Skip to content

v7.1.5-beta

Pre-release
Pre-release

Choose a tag to compare

@avgalex avgalex released this 01 Apr 12:05
· 61 commits to master since this release

What's New

ConditionalRulesMode option (Issue #203)

Controls how conditional validation rules (.When(), .Unless()) are handled during OpenAPI schema generation.

Modes:

  • Exclude (default) — conditional rules are excluded from schema (backward-compatible)
  • Include — conditional rules are included in schema
  • IncludeWithWarning — same as Include, but logs a warning for each conditional rule

Usage:

services.AddFluentValidationRulesToSwagger(options =>
{
    options.ConditionalRules = ConditionalRulesMode.Include;
});

Why: When users write .When(x => x.Prop is not null) as a null-guard, validation constraints (minLength, maxLength, etc.) were silently dropped from the schema. This option lets users opt-in to including those constraints.