MappingValidator 1.0.2
dotnet add package MappingValidator --version 1.0.2
NuGet\Install-Package MappingValidator -Version 1.0.2
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="MappingValidator" Version="1.0.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="MappingValidator" Version="1.0.2" />
<PackageReference Include="MappingValidator" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add MappingValidator --version 1.0.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: MappingValidator, 1.0.2"
#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.
#:package MappingValidator@1.0.2
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=MappingValidator&version=1.0.2
#tool nuget:?package=MappingValidator&version=1.0.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
MappingValidator
MappingValidator is a lightweight and powerful validation tool that detects missing fields in mappings between source and destination objects without relying on an external mapping library.
Dependency: .NET 9
✨ Features
- Works independently of mapping libraries (AutoMapper, Mapster, manual mapping, etc.)
- Detects fields that are not automatically or manually set in the target object
- Excludes specific fields with a customizable Ignore list
- Configurations are stored and reused by type pair (TSource, TDestination)
🚀 Installation
Reference the project as a DLL or add it via NuGet:
MappingValidator
🛠️ Usage
1. Example Model Definitions
public class Source
{
public string Name { get; set; }
public string Email { get; set; }
}
public class Destination
{
public string Name { get; set; }
public string Email { get; set; }
public string Role { get; set; }
public string CreatedBy { get; set; }
}
2. Configuration Class
@using MappingValidator
public static class MappingValidatorConfigurations
{
public static void RegisterAll()
{
MapValidator.Configure<Source, Destination>(builder =>
{
builder.Ignore(dest => dest.CreatedBy);
});
}
}
3. Add Configuration to Program.cs
MappingValidator.Configure<Source, Destination>();
4. Application Usage
@using MappingValidator
try
{
var source = new Source { Name = "Murat", Email = "murat@example.com" };
var entity = Mapper.Map<Destination>(source);
entity.Role = "Admin";
//entity.CreatedBy = "murat.koc";
MapValidator.Validate<Source, Destination>(entity);
Console.WriteLine("All manual fields set successfully!");
}
catch (Exception ex)
{
Console.WriteLine($"Error: {ex.Message}");
}
If the CreatedBy field is not set and is not added to the Ignore list:
** ValidationException:** Required fields not set on Destination: CreatedBy
🎯 When to Use?
- If there are fields that need to be filled in the target object after mapping
- If it is desired to detect missing assignments in mapping operations such as AutoMapper, Mapster, Mapperly
- If it is aimed to prevent missing data from going to the database
📄 License
MIT
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net9.0
- No dependencies.
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 |
|---|---|---|
| 1.0.2 | 210 | 6/30/2025 |