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
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#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
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Phema.Validation
C# strongly typed validation library for ASP.NET Core
Packages
Phema.Validation.Core
- Core library on top ofMicrosoft.Extensions.DepencencyInjection
Phema.Validation.Conditions
- Predefined useful conditions likeIsNot
,IsNull
,IsEmpty
etc.Phema.Validation
- Mvc integration forPhema.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
onIValidationCondition
- Store your
IValidationTemplate
's inIValidationComponent
'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(...)
onIValidationContext
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 | Versions 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.
-
.NETCoreApp 3.0
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 3.0.0-preview3.19153.1)
- Microsoft.Extensions.Options (>= 3.0.0-preview3.19153.1)
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 |
---|