Changelog
Version history for every package in the Vali-Validation ecosystem, compiled from each package's PackageReleaseNotes.
Vali-Validation (core)
3.0.0 — BREAKING CHANGE: Severity-aware validation results
ValidationResult now tracks failures with a severity (Error/Warning/Info) instead of a flat pass/fail per property. The new ValidationResult.Failures (List<ValidationFailure>) is the source of truth; Errors/ErrorCodes/ErrorsFor/HasErrorFor/FirstError/ToFlatList/ErrorCount/PropertyNames all still work exactly as before, but now only reflect Severity.Error failures — a rule marked .WithSeverity(Severity.Warning) never appears in them and never makes IsValid false.
Migration:
- No code changes required if you only ever used the old
Errors/ErrorCodes/ErrorsFor/HasErrorFor/IsValidsurface and never needWarning/Infoseverities — behavior is identical for validators that never call.WithSeverity(). - If you directly mutated
result.Errors/result.ErrorCodesor assigned them to a variable typed asDictionary<string, List<string>>, that will now fail to compile — both are nowIReadOnlyDictionary<string, List<string>>. Read-only usage (indexer reads, iteration,ContainsKey) is unaffected. - To read the new severity-aware data: use
result.Failuresdirectly, orresult.Failures.Where(f => f.PropertyName == "Email").Select(f => f.Message)instead ofresult.Errors["Email"]. - New fluent modifier:
.WithSeverity(Severity.Warning)on any property rule (same placement rules asWithMessage/WithErrorCode— only affects the last rule in the chain, and only rules added via the standard property-rule chain, notRequiredIf/EqualToPropertyand other cross-property rules). ValidationResultnow serializes (System.Text.Json, default options) as a single structured array:{ "isValid": bool, "failures": [{ "property", "message", "severity", "errorCode"? }] }— see Severity for the full example.
New features:
Severityenum (Error/Warning/Info) inVali_Validation.Core.Results.ValidationResult.Failures— single structured list, replaces the implicit two-collection (Errors/ErrorCodes) model as the source of truth.ValidationResult.AddFailure(property, message, severity, errorCode)— general-purpose failure-adding method;AddErroris now aSeverity.Error-only shorthand for it.IRuleBuilder<T,TProperty>.WithSeverity(Severity)— mark a rule as non-blocking. See Severity.CustomValidationContext<T>.AddFailure(..., Severity, ...)overloads —Custom()rules can now raise warnings too.
Rule Sets (new, non-breaking):
IRuleBuilder<T,TProperty>.InRuleSet(params string[])tags a rule; additive across calls. Rules with noInRuleSetcall carry the implicit tag"default".Validate(instance, o => o.IncludeRuleSets("name"))/ValidateAsync(...)restrict a single call to rules tagged with any of the named rule sets. PlainValidate(instance)/ValidateAsync(instance)with no options still runs every rule regardless of tag. See Rule Sets.
Block-level When/Unless (new, non-breaking):
- Protected
When(Func<T,bool>, Action)/Unless(Func<T,bool>, Action)onAbstractValidator<T>wrap multipleRuleFor/RuleForEachcalls in the constructor under a single shared condition, instead of repeating.When(...)/.Unless(...)on each rule. Nested blocks compose with AND. See Modifiers — Block-Level Conditions.
InjectValidator (new, non-breaking):
IRuleBuilder<T,TProperty>.InjectValidator<T,TProperty>(IServiceProvider)resolves a nestedIValidator<TProperty>from DI instead of requiring an already-constructed instance, then delegates toSetValidator. ThrowsInvalidOperationExceptionif noIValidator<TProperty>is registered, or the registered implementation isn't anAbstractValidator<TProperty>. See Dependency Injection.
Localization (new, non-breaking):
- Built-in rule messages ship in English (default) and Spanish, resolved automatically from
CultureInfo.CurrentUICulture. Override per call withValidate(instance, o => o.WithLanguage("es")), or set an app-wide default viaValiValidationOptions.Global.DefaultLanguage. LanguageManager.RegisterLanguage("code", dictionary)adds a new language at startup; partial catalogs are fine — any missing key falls back to English. See Localization.
Global Configuration (new, non-breaking):
ValiValidationOptions.GlobalexposesDefaultCascadeMode,DefaultLanguage,DisplayNameResolver, andPropertyNameResolveras app-wide defaults set once at startup, before any concurrent validation runs. See Global Configuration.
PropertyValidator (new, non-breaking):
IPropertyValidator<TProperty>(and thePropertyValidator<TProperty>convenience base) let you implement a custom rule as a reusable, unit-testable class instead of an inline.Must(...)predicate. Attach withRuleFor(x => x.Prop).SetPropertyValidator(new MyValidator())— integrates withWithSeverity/WithErrorCode/When/Unless/WithMessagelike any other rule. See Property Validators.
.NET 10 support:
- Multi-targeting extended to
net7.0;net8.0;net9.0;net10.0.
Fixes:
.WithMessage()/.WithErrorCode()/.WithSeverity()/.When()/.Unless()chained after.MustAsync(...)/.DependentRuleAsync(...)now correctly apply to that async rule instead of silently being dropped or reassigned to an earlier synchronous rule.
Vali-Validation.AspNetCore
1.1.0
- Adds
net10.0to the multi-targeted frameworks (nownet7.0/net8.0/net9.0/net10.0). - Now depends on
Vali-Validation3.0.0+, which brings Severity-awareValidationResult, Rule Sets, block-levelWhen/Unless,InjectValidator, Localization (English/Spanish built in),ValiValidationOptions.Global, and Property Validators to any validator used through this package's middleware/filter/attribute. No changes to this package's own public API.
1.0.0 — Initial release
ValiValidationMiddlewarecatchesValidationException, returns RFC 7807problem+json.ValiValidationFilter<T>(IEndpointFilter) for Minimal API endpoint validation.ValiValidateAttribute(IAsyncActionFilter) for MVC controller action validation.UseValiValidationExceptionHandler()middleware registration.WithValiValidation<T>()fluent extension for Minimal API routes.AddValiValidationProblemDetails()DI helper.
Vali-Validation.MediatR
1.1.0 — published today, previously 1.0.3
- Adds
net10.0to the multi-targeted frameworks (nownet7.0/net8.0/net9.0/net10.0). - Now depends on
Vali-Validation3.0.0+, which brings Severity-awareValidationResult, Rule Sets, block-levelWhen/Unless,InjectValidator, Localization (English/Spanish built in),ValiValidationOptions.Global, and Property Validators to any validator run through this pipeline behavior. No changes to this package's own public API.
1.0.0 — Initial release
ValidationBehavior<TRequest, TResponse>implementing MediatRIPipelineBehavior.- Validates request via
IValidator<TRequest>resolved from DI. - Throws
ValidationExceptionif validation fails (useVali-Validation.ValiMediatorforResult<T>-based flow). AddMediatRWithValidation()convenience extension for one-call registration.AddValiValidationBehavior()for manual MediatR setup.
Vali-Validation.ValiMediator
1.1.0
- Adds
net10.0to the multi-targeted frameworks (nownet7.0/net8.0/net9.0/net10.0). - Now depends on
Vali-Validation3.0.0+, which brings Severity-awareValidationResult, Rule Sets, block-levelWhen/Unless,InjectValidator, Localization (English/Spanish built in),ValiValidationOptions.Global, and Property Validators to any validator run through this pipeline behavior. No changes to this package's own public API.
1.0.0 — Initial release
ValidationBehavior<TRequest, TResponse>implementing Vali-MediatorIPipelineBehavior.- Validates request via
IValidator<TRequest>resolved from DI. - When
TResponseisResult<T>: returnsResult.Fail(errors, ErrorType.Validation)— no throw. - When
TResponseis any other type: throwsValidationException. AddValiValidationBehavior()extension onValiMediatorConfiguration.AddValiMediatorWithValidation()convenience extension onIServiceCollection.
Vali-Validation.TestHelpers
1.0.0 — Initial release
ShouldHaveValidationErrorFor(string propertyName)ShouldHaveValidationErrorFor(string propertyName, string expectedMessage)ShouldNotHaveValidationErrorFor(string propertyName)