Typely.Generators 0.1.0-alpha

This is a prerelease version of Typely.Generators.
There is a newer version of this package available.
See the version list below for details.
dotnet add package Typely.Generators --version 0.1.0-alpha
                    
NuGet\Install-Package Typely.Generators -Version 0.1.0-alpha
                    
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="Typely.Generators" Version="0.1.0-alpha" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Typely.Generators" Version="0.1.0-alpha" />
                    
Directory.Packages.props
<PackageReference Include="Typely.Generators" />
                    
Project file
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 Typely.Generators --version 0.1.0-alpha
                    
#r "nuget: Typely.Generators, 0.1.0-alpha"
                    
#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 Typely.Generators@0.1.0-alpha
                    
#: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=Typely.Generators&version=0.1.0-alpha&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Typely.Generators&version=0.1.0-alpha&prerelease
                    
Install as a Cake Tool

Typely

Typerly lets you create types easily with a fluent API to embrace Domain-driven design and value objects.

Example

public class TypesConfiguration : ITypelyConfiguration
{
    public void Configure(ITypelyBuilder builder)
    {
        builder.OfInt().For("Votes");
        builder.OfString().For("Username");
        builder.OfString().For("Code").Length(4).NotEqual("0000");

        // Create a reusable factory
        var sf = builder.OfString().AsFactory();

        sf.For("UserId")
            .WithNamespace("UserAggregate")
            .WithName("Owner identifier")
            .NotEmpty()
            .NotEqual("0").WithMessage("{Name} cannot be equal to {ComparisonValue}.").WithErrorCode("ERR001")
            .MaxLength(20);

        // Simplify configurations of similar types.
        var moment = sf.AsClass()
            .WithName(() => LocalizedNames.Moment)
            .MinLength(1).WithMessage(() => LocalizedMessages.MinLengthCustom)
            .MaxLength(20).WithMessage(() => LocalizedMessages.MaxLengthCustom)
            .AsFactory();

        moment.For("Monday");
        moment.For("Sunday");
    }
}

// Examples of uses:
var code = Code.From("!c9u");
var userId = UserId.From(""); //Throws ValidationException

if(!UserId.TryFrom("value", out Rating instance, out ValidationError? validationError))
{
    // Handle error
}

Why Typely?

  • The entire boiler plate is generated for you. Example here.
    • Supports value comparison with:
      • IEquatable<T>
      • Operators != and ==
    • Support for sorting with:
      • IComparable<T>
      • IComparable
    • Support for creating and validating value objects in a generic way.
    • Typely doesn't use the generic EqualityComparer and is therefore faster than records.
  • Built-in localized validations. You define the rules of the model once.
  • Built-in type conversion.
    • Accept value objects directly in the requests of your APIs.
      • No need to manually create theses objects.
      • No need to validate theirs values because they can only be created if they are valid.
    • Save or read your value objects to or from the database without effort.
  • Lets you extend your value objects easily:
    • With the use of the interface ITypelyValue<TValue, TThis>
    • Or by creating a partial class of the same name and type.
There are no supported framework assets in this 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
1.8.0 164 6/9/2024
1.7.0 1,265 10/10/2023
1.6.0 1,083 10/9/2023
1.5.0 1,441 5/10/2023
1.4.6-alpha 1,080 5/2/2023
1.4.5-alpha 1,394 5/1/2023
1.4.4-alpha 1,312 5/1/2023
1.4.3-alpha 1,117 4/28/2023
1.4.2-alpha 1,391 4/28/2023
1.4.1-alpha 1,299 4/26/2023
1.4.0-alpha 1,225 4/23/2023
1.3.2-alpha 1,075 4/23/2023
1.3.1-alpha 1,156 4/19/2023
1.3.0-alpha 1,055 4/19/2023
1.2.0-alpha 1,088 4/16/2023
1.1.0-alpha 1,180 4/16/2023
0.1.0-alpha 1,238 1/16/2023