SmartMapValidator 1.2.2
See the version list below for details.
dotnet add package SmartMapValidator --version 1.2.2
NuGet\Install-Package SmartMapValidator -Version 1.2.2
<PackageReference Include="SmartMapValidator" Version="1.2.2" />
<PackageVersion Include="SmartMapValidator" Version="1.2.2" />
<PackageReference Include="SmartMapValidator" />
paket add SmartMapValidator --version 1.2.2
#r "nuget: SmartMapValidator, 1.2.2"
#:package SmartMapValidator@1.2.2
#addin nuget:?package=SmartMapValidator&version=1.2.2
#tool nuget:?package=SmartMapValidator&version=1.2.2
SmartMapValidator
๐ง SmartMapValidator is a lightweight, attribute-based object mapping and validation library for C#. It helps you map DTOs to entities and validate properties using simple custom attributes.
๐ Features
- โ
Custom mapping with
[MapTo]attribute - ๐ซ Skip mapping with
[MapIgnore]attribute - ๐ Built-in validation support with
[Required]and[Range]attributes - ๐งฉ Modular and extensible architecture
๐ฆ Installation
You can use it locally as a class library or package it as a NuGet package.
๐น Add project reference manually:
dotnet add reference ../SmartMapValidator/SmartMapValidator.csproj
๐งช Usage Example
Define a DTO and Entity:
public class UserDto
{
[Required]
public string Name { get; set; }
[MapTo("UserAge")]
[Range(18, 99)]
public int Age { get; set; }
[MapIgnore]
public string Secret { get; set; }
}
public class UserEntity
{
public string Name { get; set; }
public int UserAge { get; set; }
}
Mapping:
var dto = new UserDto
{
Name = "Aysel",
Age = 25,
Secret = "Hidden"
};
var entity = SmartMap.Map<UserDto, UserEntity>(dto);
// entity.Name -> "Aysel"
// entity.UserAge -> 25
Validation:
var invalidDto = new UserDto
{
Name = "",
Age = 10
};
var result = SmartMap.Validate(invalidDto);
if (!result.IsValid)
{
Console.WriteLine(result.ToString());
// Output:
// Name field cannot be empty.
// Age must be between 18 and 99.
}
๐งฑ Project Structure
SmartMapValidator/
โโโ Attributes/
โ โโโ MapToAttribute.cs
โ โโโ MapIgnoreAttribute.cs
โโโ Core/
โ โโโ Mapper.cs
โ โโโ Validator.cs
โ โโโ ValidationResult.cs
โโโ Interfaces/
โ โโโ IMapDto.cs
โโโ SmartMap.cs
โโโ SmartMapValidator.csproj
๐ ๏ธ Planned Features
-
[Regex]and[StringLength]validation attributes - Nested object mapping support
- Optional AutoMapper integration
๐ License
This project is open-source and licensed under the MIT License.
โจ Author
Created by Rashad Aghayev
Contributions, pull requests, and suggestions are welcome! ๐
๐ซ Contact
If you have any questions or suggestions, feel free to contact me at:
๐ง rashadaghayev85@gmail.com
๐ฑ +994 70 818 17 00
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. 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. net9.0 was computed. 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. |
-
net8.0
- System.ComponentModel.Annotations (>= 5.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.