Phema.Validation.Core 3.0.0-preview3.0.1

This is a prerelease version of Phema.Validation.Core.
The owner has unlisted this package. This could mean that the package is deprecated, has security vulnerabilities or shouldn't be used anymore.
dotnet add package Phema.Validation.Core --version 3.0.0-preview3.0.1
NuGet\Install-Package Phema.Validation.Core -Version 3.0.0-preview3.0.1
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="Phema.Validation.Core" Version="3.0.0-preview3.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Phema.Validation.Core --version 3.0.0-preview3.0.1
#r "nuget: Phema.Validation.Core, 3.0.0-preview3.0.1"
#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.
// Install Phema.Validation.Core as a Cake Addin
#addin nuget:?package=Phema.Validation.Core&version=3.0.0-preview3.0.1&prerelease

// Install Phema.Validation.Core as a Cake Tool
#tool nuget:?package=Phema.Validation.Core&version=3.0.0-preview3.0.1&prerelease

Phema.Validation

Nuget

C# strongly typed validation library for ASP.NET Core

Packages

  • Phema.Validation.Core - Core library on top of Microsoft.Extensions.DepencencyInjection
  • Phema.Validation.Conditions - Predefined useful conditions like IsNot, IsNull, IsEmpty etc.
  • Phema.Validation - Mvc integration for Phema.Validation.Core

Usage

Phema.Validation.Core

// Add
services.AddValidation(builder => builder.AddComponent<Model, ModelValidationComponent>());

// Get
var validationContext = serviceProvider.GetRequiredService<IValidationContext>();

// Use
validationContext.When("key", "invalid")
  .Is(value => value == "invalid")
  .AddError<ModelComponent>(component => component.ValueIsInvalid);

validationContext.When(model, m => m.Value)
  .IsEqual("invalid")
  .AddError<ModelComponent>(component => component.ValueIsInvalid);
  • To check if value is valid use Is on IValidationCondition
  • Store your IValidationTemplate's in IValidationComponent's
  • To create validation messages use ValidationTemplate, ValidationTemplate<TArg1>, ValidationTemplate<TArg1, TArg2>, etc. or write your custom
  • Validate model value using expression manner model, m => m.Value
  • To override key use [DataMember(Name = "key")] attribute
  • Check that context is valid by calling IsValid(model, m => m.Value)/EnsureIsValid(...) on IValidationContext

Phema.Validation.Conditions

validationContext.When("key", "invalid value")
  .IsEqual("invalid value")
  .AddError<ModelComponent>(component => component.ValueIsInvalid);
  • Predefined conditions like IsNot, IsNull, IsEmpty, IsEqual etc.

Phema.Validation

services.AddMvcCore()
  .AddValidation(builder =>
    builder.AddValidationComponent<Model, ModelValidation, ModelValidationComponent>())
  • To validate mvc input implement IValidator<TModel> interface
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  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. 
.NET Core netcoreapp3.0 is compatible.  netcoreapp3.1 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