Referencia Pública de API .NETL0 Primitivas FundamentalesEstableAOT: Parcial

EricksonLopez.DomainPrimitives

High-performance, AOT-ready Domain Primitives for .NET 8+. Generates secure, immutable value objects with deep BCL integration, including IUtf8SpanParsable, for robust domain modeling with minimal overhead.

11 namespaces117 tipos298 miembrosGenerado desde XML docs y ensamblados · UTC 2026-12-01

Mostrando 117 de 117 tipos (298 miembros)

EricksonLopez.DomainPrimitives#

70
class

AgeAttribute

Ensamblado: EricksonLopez.DomainPrimitives.Abstractions
public sealed class AgeAttribute : Attribute
Hereda de: Attribute

Specifies that a struct is an age domain primitive. Equivalent to: `[NumericPrimitive<int>] [PrimitiveRange(0, 150)]`.

Miembros (0)

Este tipo declara 0 miembros públicos (por ejemplo, interfaz marcadora o enum/record vacío).

class

BirthDateAttribute

Ensamblado: EricksonLopez.DomainPrimitives.Abstractions
public sealed class BirthDateAttribute : Attribute
Hereda de: Attribute

Specifies that a struct is a birth date domain primitive. Equivalent to: `[DatePrimitive(Kind = DateOnly, PastOnly = true)]`.

Notas:

Validates that the date is in the past and not more than `MaxAge` years ago. Generates an `Age` computed property.

Miembros (1)

  • propertyMaxAge
    public int MaxAge { get; init; }

    Gets the maximum allowed age in years. Default: 150.

class

BusinessDateAttribute

Ensamblado: EricksonLopez.DomainPrimitives.Abstractions
public sealed class BusinessDateAttribute : Attribute
Hereda de: Attribute

Specifies that a struct is a business date domain primitive.

Miembros (1)

  • propertyAllowWeekends
    public bool AllowWeekends { get; init; }

    Gets a value indicating whether weekend dates are allowed. Default: `false`.

class

CountryCodeAttribute

Ensamblado: EricksonLopez.DomainPrimitives.Abstractions
public sealed class CountryCodeAttribute : Attribute
Hereda de: Attribute

Specifies that a struct is an ISO 3166-1 alpha-2 country code (e.g., "US", "DE"). Equivalent to: `[StringPrimitive] [Trim] [UpperCase] [Length(2, 2)]`.

Miembros (0)

Este tipo declara 0 miembros públicos (por ejemplo, interfaz marcadora o enum/record vacío).

class

CurrencyCodeAttribute

Ensamblado: EricksonLopez.DomainPrimitives.Abstractions
public sealed class CurrencyCodeAttribute : Attribute
Hereda de: Attribute

Specifies that a struct is an ISO 4217 currency code (e.g., "USD", "EUR"). Equivalent to: `[StringPrimitive] [Trim] [UpperCase] [Length(3, 3)]`.

Miembros (0)

Este tipo declara 0 miembros públicos (por ejemplo, interfaz marcadora o enum/record vacío).

class

DatePrimitiveAttribute

Ensamblado: EricksonLopez.DomainPrimitives.Abstractions
public sealed class DatePrimitiveAttribute : Attribute
Hereda de: Attribute

Specifies that a struct is a date- or time-backed domain primitive.

Notas:

Use this attribute for temporal values that carry domain-specific validation or calculation rules. Use `Kind` to select the backing type. For domain-specific date types, use shortcut attributes like `BirthDateAttribute`, `ExpirationDateAttribute`. Example:

[DatePrimitive(Kind = DatePrimitiveKind.DateOnly)]
public readonly partial record struct RegistrationDate;

Miembros (3)

  • propertyFutureOnly
    public bool FutureOnly { get; init; }

    Gets a value indicating whether only future dates or times are allowed (after current UTC time).

  • propertyKind
    public DatePrimitiveKind Kind { get; init; }

    Gets the backing temporal type. Default: `DatePrimitiveKind.DateOnly`.

  • propertyPastOnly
    public bool PastOnly { get; init; }

    Gets a value indicating whether only past dates or times are allowed (before current UTC time).

enum

DatePrimitiveKind

Ensamblado: EricksonLopez.DomainPrimitives.Abstractions
public enum DatePrimitiveKind

Specifies the backing temporal type for a date primitive.

Miembros (4)

  • fieldDateOnly
    DateOnly

    Specifies backing by `System.DateOnly` for dates without time components.

  • fieldDateTime
    DateTime

    Specifies backing by `System.DateTime` when both date and time are needed.

  • fieldDateTimeOffset
    DateTimeOffset

    Specifies backing by `System.DateTimeOffset` when timezone-aware timestamps are needed.

  • fieldTimeOnly
    TimeOnly

    Specifies backing by `System.TimeOnly` for time-of-day without a date component.

class

DateRangeAttribute

Ensamblado: EricksonLopez.DomainPrimitives.Abstractions
public sealed class DateRangeAttribute : Attribute
Hereda de: Attribute

Specifies that a struct is a date range domain primitive. Architectural Guidance: In Domain-Driven Design, when modeling a compound interval with both start and end timestamps and cross-property validation (`Start <= End`), prefer creating a compound `[ValueObject]`.

Miembros (0)

Este tipo declara 0 miembros públicos (por ejemplo, interfaz marcadora o enum/record vacío).

class

DiscountAttribute

Ensamblado: EricksonLopez.DomainPrimitives.Abstractions
public sealed class DiscountAttribute : Attribute
Hereda de: Attribute

Specifies that a struct is a discount domain primitive. Equivalent to: `[NumericPrimitive<decimal>] [PrimitiveRange(0, 100)]`.

Notas:

Represents a discount as a percentage (e.g., 15.0 for 15% off).

Miembros (2)

  • propertyMax
    public double Max { get; init; }

    Gets the maximum discount percentage. Default: 100.

  • propertyMin
    public double Min { get; init; }

    Gets the minimum discount percentage. Default: 0.

class

DistanceAttribute

Ensamblado: EricksonLopez.DomainPrimitives.Abstractions
public sealed class DistanceAttribute : Attribute
Hereda de: Attribute

Specifies that a struct is a distance domain primitive. Equivalent to: `[NumericPrimitive<double>] [PrimitiveRange(0, double.MaxValue)]`.

Notas:

Represents distance in meters (SI unit). No upper bound by default — suitable for geographic distances. Override `Max` for domain-specific constraints.

Miembros (2)

  • propertyMax
    public double Max { get; init; }

    Gets the maximum allowed distance in meters. Default: `double.MaxValue`.

  • propertyMin
    public double Min { get; init; }

    Gets the minimum allowed distance in meters. Default: 0.

class

DomainPrimitiveValidationException

Ensamblado: EricksonLopez.DomainPrimitives.Abstractions
public sealed class DomainPrimitiveValidationException : ArgumentException
Hereda de: ArgumentException

Represents the exception thrown when a domain primitive cannot be created due to invalid input.

Notas:

Inherits from `ArgumentException` so callers can catch it with either `catch (DomainPrimitiveValidationException)` or `catch (ArgumentException)`. This exception is thrown by the generated `Create(TValue)` factory method. For non-throwing creation, use the generated `TryCreate(TValue, out TSelf, out PrimitiveError)` overload instead.

Miembros (5)

  • constructorDomainPrimitiveValidationException
    public DomainPrimitiveValidationException(PrimitiveError error)

    Initializes a new instance of the `DomainPrimitiveValidationException` class with a structured validation error.

    error: PrimitiveError
    The structured validation error containing the error code and message.
  • constructorDomainPrimitiveValidationException
    public DomainPrimitiveValidationException(PrimitiveError error, Exception? innerException)

    Initializes a new instance of the `DomainPrimitiveValidationException` class with a structured validation error and an inner exception.

    error: PrimitiveError
    The structured validation error containing the error code and message.
    innerException: Exception?
    The exception that is the cause of the current exception.
  • constructorDomainPrimitiveValidationException
    public DomainPrimitiveValidationException(PrimitiveError error, Exception? innerException, string paramName)

    Initializes a new instance of the `DomainPrimitiveValidationException` class with a structured validation error, an inner exception, and a parameter name.

    error: PrimitiveError
    The structured validation error containing the error code and message.
    innerException: Exception?
    The exception that is the cause of the current exception.
    paramName: string
    The name of the parameter that caused the exception.
  • constructorDomainPrimitiveValidationException
    public DomainPrimitiveValidationException(PrimitiveError error, string paramName)

    Initializes a new instance of the `DomainPrimitiveValidationException` class with a structured validation error and a parameter name.

    error: PrimitiveError
    The structured validation error containing the error code and message.
    paramName: string
    The name of the parameter that caused the exception.
  • propertyError
    public PrimitiveError Error { get; }

    Gets the structured validation error that caused the exception.

    Use this property to access the machine-readable error code and message without parsing the exception message string.

class

DomainPrimitivesDefaultsAttribute

Ensamblado: EricksonLopez.DomainPrimitives.Abstractions
public sealed class DomainPrimitivesDefaultsAttribute : Attribute
Hereda de: Attribute

Specifies global default policies for domain primitives generated in this assembly.

Notas:

Per-type attributes take precedence over global assembly defaults.

Miembros (4)

  • propertyExceptionType
    public Type? ExceptionType { get; set; }

    Gets or sets a custom exception type to throw on validation failures in `Create()`. The exception type must inherit from `Exception` and provide a constructor accepting a string message. If not specified, `DomainPrimitiveValidationException` is thrown.

  • propertyMaxLength
    public int MaxLength { get; set; }

    Gets or sets a default maximum length for string primitives when no explicit length is specified. Default is 4096 (security limit).

  • propertyNotEmpty
    public bool NotEmpty { get; set; }

    Gets or sets a value indicating whether string primitives should automatically enforce not-empty validation by default.

  • propertyTrim
    public bool Trim { get; set; }

    Gets or sets a value indicating whether string primitives should automatically trim whitespace by default.

class

EmailAttribute

Ensamblado: EricksonLopez.DomainPrimitives.Abstractions
public sealed class EmailAttribute : Attribute
Hereda de: Attribute

Specifies that a struct is an email address domain primitive. Equivalent to: `[StringPrimitive] [Trim] [LowerCase] [MaxLength(254)] [Regex(RFC5322)]`.

Notas:

Generates RFC 5322-compliant email validation with automatic trimming and lowercasing. Override `MaxLength` to change the default 254-character limit. Example:

[Email]
public readonly partial record struct EmailAddress;

Miembros (1)

  • propertyMaxLength
    public int MaxLength { get; init; }

    Gets the maximum length. Default: 254 (RFC 5321 path limit).

class

ExactLengthAttribute

Ensamblado: EricksonLopez.DomainPrimitives.Abstractions
public sealed class ExactLengthAttribute : Attribute
Hereda de: Attribute

Specifies that a string domain primitive must have exactly `n` characters.

Notas:

Convenience shortcut for `[Length(n, n)]`. The generated code enforces `value.Length == length` with a `"LENGTH"` error code. Common uses: ISO 3166-1 alpha-2 country codes (2), VIN numbers (17), IBAN check digits, etc. Example:

[StringPrimitive]
[ExactLength(2)]
public readonly partial record struct IsoAlpha2Code;

Miembros (4)

  • constructorExactLengthAttribute
    public ExactLengthAttribute(int length)

    Initializes a new instance of the `ExactLengthAttribute` class with the specified exact length.

    length: int
    The exact number of characters the value must have.
  • propertyErrorCode
    public string? ErrorCode { get; set; }

    Gets or sets the error code emitted when the constraint is violated. Defaults to `"LENGTH"`.

  • propertyErrorMessage
    public string? ErrorMessage { get; set; }

    Gets or sets the error message. If null, the generator produces a message with the expected length and actual length.

  • propertyLength
    public int Length { get; }

    Gets the required exact length.

class

ExpirationDateAttribute

Ensamblado: EricksonLopez.DomainPrimitives.Abstractions
public sealed class ExpirationDateAttribute : Attribute
Hereda de: Attribute

Specifies that a struct is an expiration date domain primitive. Equivalent to: `[DatePrimitive(Kind = DateOnly, FutureOnly = true)]`.

Notas:

Validates that the date is in the future. Generates `IsExpired()` and `DaysUntilExpiration()` methods.

Miembros (0)

Este tipo declara 0 miembros públicos (por ejemplo, interfaz marcadora o enum/record vacío).

class

FiscalYearAttribute

Ensamblado: EricksonLopez.DomainPrimitives.Abstractions
public sealed class FiscalYearAttribute : Attribute
Hereda de: Attribute

Specifies that a struct is a fiscal year domain primitive.

Miembros (1)

  • propertyMinYear
    public int MinYear { get; init; }

    Gets the minimum valid fiscal year. Default: 1900.

class

HeightAttribute

Ensamblado: EricksonLopez.DomainPrimitives.Abstractions
public sealed class HeightAttribute : Attribute
Hereda de: Attribute

Specifies that a struct is a height domain primitive. Equivalent to: `[NumericPrimitive<double>] [PrimitiveRange(0, 300)]`.

Notas:

Represents height in centimeters. Maximum 300 cm covers the tallest recorded human measurements.

Miembros (2)

  • propertyMax
    public double Max { get; init; }

    Gets the maximum allowed height in cm. Default: 300.

  • propertyMin
    public double Min { get; init; }

    Gets the minimum allowed height in cm. Default: 0.

class

HexColorAttribute

Ensamblado: EricksonLopez.DomainPrimitives.Abstractions
public sealed class HexColorAttribute : Attribute
Hereda de: Attribute

Specifies that a struct is a CSS hex color domain primitive (e.g., "#FF5733"). Equivalent to: `[StringPrimitive] [Trim] [UpperCase] [Regex(hex-color)]`.

Miembros (0)

Este tipo declara 0 miembros públicos (por ejemplo, interfaz marcadora o enum/record vacío).

class

IBANAttribute

Ensamblado: EricksonLopez.DomainPrimitives.Abstractions
public sealed class IBANAttribute : Attribute
Hereda de: Attribute

Specifies that a struct is an International Bank Account Number (IBAN) domain primitive. Equivalent to: `[StringPrimitive] [Trim] [UpperCase] [Regex(iban-pattern)]`.

Miembros (0)

Este tipo declara 0 miembros públicos (por ejemplo, interfaz marcadora o enum/record vacío).

interface

IDomainPrimitive<TSelf>

Ensamblado: EricksonLopez.DomainPrimitives.Abstractions
public interface IDomainPrimitive<TSelf> where TSelf : IDomainPrimitive<TSelf>

Defines the contract for all domain primitive types. Enables generic constraints and discovery without introducing runtime overhead.

Notas:

All domain primitives — strong IDs, string primitives, numeric primitives, date primitives, smart enums, and composite value objects — implement this interface. This interface uses the Curiously Recurring Template Pattern (CRTP) to enable `static abstract` members that return the concrete type. Type parameters: TSelf: The concrete domain primitive type (CRTP pattern).

Miembros (2)

  • propertyIsDefault
    bool IsDefault { get; }

    Gets a value indicating whether this instance was created via `default` rather than a factory method.

    A default instance carries no validated value. Callers should check this property before accessing value properties to avoid operating on uninitialized data.

  • propertyPrimitiveName
    static abstract string PrimitiveName { get; }

    Gets the name of this domain primitive type, used in diagnostics, error messages, and observability.

    Example:

    // For a type "CustomerId", this returns "CustomerId"
    string name = CustomerId.PrimitiveName; // "CustomerId"
interface

IDomainPrimitive<TSelf, TValue>

Ensamblado: EricksonLopez.DomainPrimitives.Abstractions
public interface IDomainPrimitive<TSelf, TValue> : IDomainPrimitive<TSelf> where TSelf : IDomainPrimitive<TSelf, TValue> where TValue : notnull
Implementa: IDomainPrimitive<TSelf>

Defines a domain primitive wrapping a single backing value of type `TValue`.

Notas:

Provides the standard factory methods (`Create` and `TryCreate(TValue, out TSelf, out PrimitiveError)`) for creating valid instances. Direct construction is blocked by the source generator, which generates a private constructor. `Create` throws on invalid input. `TryCreate(TValue, out TSelf, out PrimitiveError)` provides exception-free validation. Type parameters: TSelf: The concrete domain primitive type (CRTP pattern).; TValue: The underlying primitive type (e.g., `Guid`, `string`, `decimal`).

Miembros (3)

  • methodCreate
    static abstract TSelf Create(TValue value)

    Creates a new, validated instance from the specified raw value, applying normalization before validation.

    value: TValue
    The raw value to normalize and validate.

    Retorna: A valid, normalized domain primitive instance.

  • methodTryCreate
    static abstract bool TryCreate(TValue value, out TSelf result, out global::EricksonLopez.DomainPrimitives.Validation.PrimitiveError validationError)

    Attempts to create a new, validated instance from the specified raw value without throwing on failure.

    value: TValue
    The raw value to normalize and validate.
    result: out TSelf
    When this method returns `true`, contains the valid primitive instance; otherwise, the default value for `TSelf`.
    validationError: out global::EricksonLopez.DomainPrimitives.Validation.PrimitiveError
    When this method returns `false`, contains the first validation error that occurred.

    Retorna: `true` if the instance was created successfully; otherwise, `false`.

  • propertyValue
    TValue Value { get; }

    Gets the validated, normalized underlying value wrapped by this domain primitive.

interface

IGuidStrongId<TSelf>

Ensamblado: EricksonLopez.DomainPrimitives.Abstractions
public interface IGuidStrongId<TSelf> : IStrongId<TSelf, Guid> where TSelf : struct, IGuidStrongId<TSelf>
Implementa: IStrongId<TSelf, Guid>

Defines the contract for strongly-typed identifiers backed by a `Guid` that support parameterless generation of unique values via `Create()`.

Notas:

Type parameters: TSelf: The concrete strong ID type (CRTP pattern).

Miembros (1)

  • methodCreate
    new static abstract TSelf Create()

    Creates a new, unique identifier using a newly generated `Guid`.

    Retorna: A new strong ID wrapping a freshly generated `Guid`.

interface

INormalizer<T>

Ensamblado: EricksonLopez.DomainPrimitives.Abstractions
public interface INormalizer<T>

Defines a contract for a custom normalization strategy.

Notas:

Type parameters: T: The type of value to normalize.

Miembros (1)

  • methodNormalize
    static abstract T Normalize(T value)

    Normalizes the specified input value.

    value: T
    The value to normalize.

    Retorna: The normalized value resulting from the transformation.

class

IPAddressAttribute

Ensamblado: EricksonLopez.DomainPrimitives.Abstractions
public sealed class IPAddressAttribute : Attribute
Hereda de: Attribute

Specifies that a struct is an IPv4 or IPv6 address domain primitive. Equivalent to: `[StringPrimitive] [Trim] [Regex(ip-pattern)]`.

Miembros (0)

Este tipo declara 0 miembros públicos (por ejemplo, interfaz marcadora o enum/record vacío).

class

ISBNAttribute

Ensamblado: EricksonLopez.DomainPrimitives.Abstractions
public sealed class ISBNAttribute : Attribute
Hereda de: Attribute

Specifies that a struct is an International Standard Book Number (ISBN) domain primitive. Equivalent to: `[StringPrimitive] [Trim] [Regex(isbn-pattern)]`.

Miembros (0)

Este tipo declara 0 miembros públicos (por ejemplo, interfaz marcadora o enum/record vacío).

interface

IStrongId<TSelf, TValue>

Ensamblado: EricksonLopez.DomainPrimitives.Abstractions
public interface IStrongId<TSelf, TValue> : IDomainPrimitive<TSelf, TValue> where TSelf : IStrongId<TSelf, TValue> where TValue : notnull
Implementa: IDomainPrimitive<TSelf, TValue>

Defines the contract for strongly-typed identifiers.

Notas:

Strong IDs provide type-safe identity wrappers that prevent accidental interchange of identifiers (e.g., passing a `ProductId` where a `CustomerId` is expected). Unlike other domain primitives, strong IDs have no validation beyond the underlying type constraints. They provide: - `Create()` — creates a new unique identifier - `Empty` — an uninitialized/empty sentinel Type parameters: TSelf: The concrete strong ID type (CRTP pattern).; TValue: The backing identity type (e.g., `Guid`, `int`, `long`).

Miembros (2)

  • methodCreate
    static abstract TSelf Create()

    Creates a new, unique identifier.

    Retorna: A new strong ID wrapping a freshly generated value.

    Deprecated: Parameterless creation is only valid for Guid-backed identifiers. Use `IGuidStrongId<TSelf>.Create` for Guid IDs, or `IDomainPrimitive<TSelf, TValue>.Create(TValue)` with an explicit value.

  • propertyEmpty
    static abstract TSelf Empty { get; }

    Gets the empty or uninitialized sentinel value for this identifier type.

    Equivalent to `default` for the backing type, but explicitly named for discoverability and intent.

class

LanguageCodeAttribute

Ensamblado: EricksonLopez.DomainPrimitives.Abstractions
public sealed class LanguageCodeAttribute : Attribute
Hereda de: Attribute

Specifies that a struct is an ISO 639-1 language code (e.g., "en", "es"). Equivalent to: `[StringPrimitive] [Trim] [LowerCase] [Length(2, 2)]`.

Miembros (0)

Este tipo declara 0 miembros públicos (por ejemplo, interfaz marcadora o enum/record vacío).

class

LatitudeAttribute

Ensamblado: EricksonLopez.DomainPrimitives.Abstractions
public sealed class LatitudeAttribute : Attribute
Hereda de: Attribute

Specifies that a struct is a latitude domain primitive. Equivalent to: `[NumericPrimitive<double>] [PrimitiveRange(-90, 90)]`.

Miembros (0)

Este tipo declara 0 miembros públicos (por ejemplo, interfaz marcadora o enum/record vacío).

class

LengthAttribute

Ensamblado: EricksonLopez.DomainPrimitives.Abstractions
public sealed class LengthAttribute : Attribute
Hereda de: Attribute

Specifies both minimum and maximum length for a string domain primitive.

Notas:

Combines `MinLengthAttribute` and `MaxLengthAttribute` in a single attribute. The generated error code is `"LENGTH"` by default and can be customized via `ErrorCode`.

Miembros (5)

  • constructorLengthAttribute
    public LengthAttribute(int min, int max)

    Initializes a new instance of the `LengthAttribute` class with the specified minimum and maximum lengths.

    min: int
    The minimum allowed length (inclusive).
    max: int
    The maximum allowed length (inclusive).
  • propertyErrorCode
    public string? ErrorCode { get; set; }

    Gets or sets the error code emitted when the length constraint is violated. Defaults to `"LENGTH"`.

  • propertyErrorMessage
    public string? ErrorMessage { get; set; }

    Gets or sets the error message emitted when the length constraint is violated.

  • propertyMax
    public int Max { get; }

    Gets the maximum allowed length (inclusive).

  • propertyMin
    public int Min { get; }

    Gets the minimum allowed length (inclusive).

class

LongitudeAttribute

Ensamblado: EricksonLopez.DomainPrimitives.Abstractions
public sealed class LongitudeAttribute : Attribute
Hereda de: Attribute

Specifies that a struct is a longitude domain primitive. Equivalent to: `[NumericPrimitive<double>] [PrimitiveRange(-180, 180)]`.

Miembros (0)

Este tipo declara 0 miembros públicos (por ejemplo, interfaz marcadora o enum/record vacío).

class

LowerCaseAttribute

Ensamblado: EricksonLopez.DomainPrimitives.Abstractions
public sealed class LowerCaseAttribute : Attribute
Hereda de: Attribute

Specifies that a string domain primitive should be converted to lower case before validation.

Miembros (0)

Este tipo declara 0 miembros públicos (por ejemplo, interfaz marcadora o enum/record vacío).

class

MacAddressAttribute

Ensamblado: EricksonLopez.DomainPrimitives.Abstractions
public sealed class MacAddressAttribute : Attribute
Hereda de: Attribute

Specifies that a struct is a MAC address domain primitive. Equivalent to: `[StringPrimitive] [Trim] [UpperCase] [Regex(mac-pattern)]`.

Miembros (0)

Este tipo declara 0 miembros públicos (por ejemplo, interfaz marcadora o enum/record vacío).

class

MaxLengthAttribute

Ensamblado: EricksonLopez.DomainPrimitives.Abstractions
public sealed class MaxLengthAttribute : Attribute
Hereda de: Attribute

Specifies the maximum length for a string domain primitive.

Miembros (4)

  • constructorMaxLengthAttribute
    public MaxLengthAttribute(int length)

    Initializes a new instance of the `MaxLengthAttribute` class with the specified maximum length.

    length: int
    The maximum number of characters the value may have (inclusive).
  • propertyErrorCode
    public string? ErrorCode { get; set; }

    Gets or sets the error code emitted when the constraint is violated. Defaults to `"LENGTH"`.

  • propertyErrorMessage
    public string? ErrorMessage { get; set; }

    Gets or sets the error message emitted when the value exceeds the maximum length.

  • propertyLength
    public int Length { get; }

    Gets the maximum allowed length (inclusive).

class

MinLengthAttribute

Ensamblado: EricksonLopez.DomainPrimitives.Abstractions
public sealed class MinLengthAttribute : Attribute
Hereda de: Attribute

Specifies the minimum length for a string domain primitive.

Miembros (4)

  • constructorMinLengthAttribute
    public MinLengthAttribute(int length)

    Initializes a new instance of the `MinLengthAttribute` class with the specified minimum length.

    length: int
    The minimum number of characters the value must have (inclusive).
  • propertyErrorCode
    public string? ErrorCode { get; set; }

    Gets or sets the error code emitted when the constraint is violated. Defaults to `"LENGTH"`.

  • propertyErrorMessage
    public string? ErrorMessage { get; set; }

    Gets or sets the error message emitted when the value is shorter than the minimum length.

  • propertyLength
    public int Length { get; }

    Gets the minimum required length (inclusive).

class

MoneyAttribute

Ensamblado: EricksonLopez.DomainPrimitives.Abstractions
public sealed class MoneyAttribute : Attribute
Hereda de: Attribute

Specifies that a struct is a monetary value domain primitive. Equivalent to: `[NumericPrimitive<decimal>] [PrimitiveRange(0, max)]` with addition, subtraction, and scalar multiplication/division operators.

Miembros (6)

  • constructorMoneyAttribute
    public MoneyAttribute()

    Initializes a new instance of the `MoneyAttribute` class with default USD currency and no explicit range constraints.

  • constructorMoneyAttribute
    public MoneyAttribute(string currency)

    Initializes a new instance of the `MoneyAttribute` class with the specified currency code.

    currency: string
    The ISO 4217 currency code (e.g., `"USD"`, `"EUR"`).
  • constructorMoneyAttribute
    public MoneyAttribute(string currency, double min, double max = double.MaxValue)

    Initializes a new instance of the `MoneyAttribute` class with the specified currency code and value range.

    currency: string
    The ISO 4217 currency code (e.g., `"USD"`, `"EUR"`).
    min: double
    The minimum allowed monetary value (inclusive). Use 0 for non-negative amounts.
    max: double
    The maximum allowed monetary value (inclusive). Defaults to `double.MaxValue`.
  • propertyCurrency
    public string Currency { get; init; }

    Gets the ISO 4217 currency code. Default: "USD".

  • propertyMax
    public double Max { get; init; }

    Gets the maximum allowed value. Default: `double.MaxValue`.

  • propertyMin
    public double Min { get; init; }

    Gets the minimum allowed value. Default: 0.

class

MonthAttribute

Ensamblado: EricksonLopez.DomainPrimitives.Abstractions
public sealed class MonthAttribute : Attribute
Hereda de: Attribute

Specifies that a struct is a month domain primitive.

Miembros (0)

Este tipo declara 0 miembros públicos (por ejemplo, interfaz marcadora o enum/record vacío).

class

NormalizeAttribute<TNormalizer>

Ensamblado: EricksonLopez.DomainPrimitives.Abstractions
public sealed class NormalizeAttribute<TNormalizer> : Attribute
Hereda de: Attribute

Specifies a custom normalization strategy to apply to a domain primitive.

Notas:

The normalizer is invoked before validation. Multiple `[Normalize]` attributes can be stacked. Type parameters: TNormalizer: The normalizer type implementing `INormalizer<T>`. Example:

[StringPrimitive]
[Normalize<RemoveSpacesNormalizer>]
public readonly partial record struct Code;

Miembros (0)

Este tipo declara 0 miembros públicos (por ejemplo, interfaz marcadora o enum/record vacío).

class

NormalizeWhitespaceAttribute

Ensamblado: EricksonLopez.DomainPrimitives.Abstractions
public sealed class NormalizeWhitespaceAttribute : Attribute
Hereda de: Attribute

Specifies that internal whitespace should be normalized by collapsing consecutive whitespace characters into a single space.

Notas:

Applied after `TrimAttribute` in the normalization pipeline. Useful for display names, titles, and similar user-facing strings.

Miembros (0)

Este tipo declara 0 miembros públicos (por ejemplo, interfaz marcadora o enum/record vacío).

class

NotEmptyAttribute

Ensamblado: EricksonLopez.DomainPrimitives.Abstractions
public sealed class NotEmptyAttribute : Attribute
Hereda de: Attribute

Specifies that a string domain primitive must not be empty or whitespace-only.

Miembros (2)

  • propertyErrorCode
    public string? ErrorCode { get; set; }

    Gets or sets the error code emitted when the value is empty or whitespace-only. Defaults to `"EMPTY"`.

  • propertyErrorMessage
    public string? ErrorMessage { get; set; }

    Gets or sets the error message emitted when the value is empty or whitespace-only.

enum

NumericOperations

Ensamblado: EricksonLopez.DomainPrimitives.Abstractions
public enum NumericOperations

Defines the allowed arithmetic operations for a numeric domain primitive.

Miembros (9)

  • fieldAddition
    Addition = 1<<0

    Allows addition.

  • fieldAdditive
    Additive = Addition|Subtraction|Negation

    Allows addition and subtraction.

  • fieldAll
    All = Additive|Multiplicative

    Allows all arithmetic operations.

  • fieldMultiplicative
    Multiplicative = ScalarMultiplication|ScalarDivision

    Allows scalar multiplication and division.

  • fieldNegation
    Negation = 1<<4

    Allows unary negation.

  • fieldNone
    None = 0

    No arithmetic operations are allowed.

  • fieldScalarDivision
    ScalarDivision = 1<<3

    Allows scalar division.

  • fieldScalarMultiplication
    ScalarMultiplication = 1<<2

    Allows scalar multiplication.

  • fieldSubtraction
    Subtraction = 1<<1

    Allows subtraction.

class

NumericPrimitiveAttribute<TValue>

Ensamblado: EricksonLopez.DomainPrimitives.Abstractions
public sealed class NumericPrimitiveAttribute<TValue> : Attribute where TValue : struct, INumber<TValue>
Hereda de: Attribute

Specifies that a struct is a numeric-backed domain primitive.

Notas:

Use this attribute for numeric values that carry domain semantics beyond their raw numeric value. Combine with `PrimitiveRangeAttribute` to constrain the allowed range. The source generator produces comparison operators, equality, formatting, and parsing implementations. Arithmetic operators are generated based on the `NumericOperations` value. For domain-specific numeric types, use shortcut attributes like `MoneyAttribute`, `PercentageAttribute`. Type parameters: TValue: The backing numeric type (e.g., `int`, `decimal`, `double`). Example:

[NumericPrimitive<decimal>(Operations = NumericOperations.Additive)]
[PrimitiveRange(0, 100)]
public readonly partial record struct Score;

Miembros (1)

  • propertyOperations
    public NumericOperations Operations { get; init; }

    Gets the allowed arithmetic operations for this numeric domain primitive. Default is `NumericOperations.None`.

class

PasswordHashAttribute

Ensamblado: EricksonLopez.DomainPrimitives.Abstractions
public sealed class PasswordHashAttribute : Attribute
Hereda de: Attribute

Specifies that a struct is a password hash domain primitive. Equivalent to: `[StringPrimitive] [NotEmpty]`.

Notas:

No normalization is applied — hashes must never be trimmed or case-changed.

Miembros (0)

Este tipo declara 0 miembros públicos (por ejemplo, interfaz marcadora o enum/record vacío).

class

PercentageAttribute

Ensamblado: EricksonLopez.DomainPrimitives.Abstractions
public sealed class PercentageAttribute : Attribute
Hereda de: Attribute

Specifies that a struct is a percentage value domain primitive (0-100 scale). Equivalent to: `[NumericPrimitive<decimal>] [PrimitiveRange(0, 100)]`.

Miembros (2)

  • propertyMax
    public double Max { get; init; }

    Gets the maximum allowed value. Default: 100.

  • propertyMin
    public double Min { get; init; }

    Gets the minimum allowed value. Default: 0.

class

PhoneAttribute

Ensamblado: EricksonLopez.DomainPrimitives.Abstractions
public sealed class PhoneAttribute : Attribute
Hereda de: Attribute

Specifies that a struct is a phone number domain primitive. Equivalent to: `[StringPrimitive] [Trim] [Regex(E.164)]`.

Notas:

Generates E.164-compliant phone number validation.

Miembros (0)

Este tipo declara 0 miembros públicos (por ejemplo, interfaz marcadora o enum/record vacío).

class

PriceAttribute

Ensamblado: EricksonLopez.DomainPrimitives.Abstractions
public sealed class PriceAttribute : Attribute
Hereda de: Attribute

Specifies that a struct is a price domain primitive. Equivalent to: `[NumericPrimitive<decimal>] [PrimitiveRange(0, double.MaxValue)]` with addition and subtraction operators.

Notas:

Differs from `MoneyAttribute` in that it does not carry a currency code. Use `MoneyAttribute` when the currency is part of the domain concept.

Miembros (2)

  • propertyMax
    public double Max { get; init; }

    Gets the maximum price. Default: `double.MaxValue`.

  • propertyMin
    public double Min { get; init; }

    Gets the minimum price. Default: 0.

class

PrimitiveCollectionExtensions

Ensamblado: EricksonLopez.DomainPrimitives.Abstractions
public static class PrimitiveCollectionExtensions

Provides extension methods for converting collections of raw values into collections of domain primitives.

Miembros (5)

  • methodToDomainPrimitiveArray<TPrimitive, TValue>
    public static TPrimitive[] ToDomainPrimitiveArray<TPrimitive, TValue>(this IEnumerable<TValue> values) where TPrimitive : struct, IDomainPrimitive<TPrimitive, TValue> where TValue : notnull

    Creates an array of domain primitives by creating each element from the corresponding raw value.

    values: this IEnumerable<TValue>
    The sequence of raw values to convert.

    Retorna: A new array containing one validated domain primitive for each element in `values`. Never returns `null` but may be empty if the source sequence is empty.

    For sequences that implement `ICollection<T>`, the output array is pre-allocated to the exact count. For other enumerables, elements are buffered before conversion. Type parameters: TPrimitive: The domain primitive struct type to create.; TValue: The raw backing value type. Exceptions: ArgumentException: An element in `values` fails domain validation rules. The `Exception.InnerException` is a `DomainPrimitiveValidationException` carrying the structured error code and the zero-based element index is included in the exception message; NotSupportedException: The target framework is below .NET 7.0, which does not support static abstract interface members

  • methodToDomainPrimitiveArray<TPrimitive, TValue>
    public static TPrimitive[] ToDomainPrimitiveArray<TPrimitive, TValue>(this IEnumerable<TValue> values, Func<TValue, TPrimitive> factory) where TPrimitive : struct where TValue : notnull

    Creates an array of domain primitives by invoking `factory` for each raw value.

    values: this IEnumerable<TValue>
    The sequence of raw values to convert.
    factory: Func<TValue, TPrimitive>
    The factory delegate used to construct each domain primitive.

    Retorna: A new array containing one domain primitive for each element in `values`.

    This overload is available on all supported platforms, including netstandard2.0, where static abstract interface members are not available. Type parameters: TPrimitive: The domain primitive struct type to create.; TValue: The raw backing value type. Exceptions: ArgumentNullException: `values` or `factory` is `null`; ArgumentException: An element in `values` fails domain validation

  • methodToDomainPrimitiveArray<TPrimitive, TValue>
    public static TPrimitive[] ToDomainPrimitiveArray<TPrimitive, TValue>(this System.ReadOnlySpan<TValue> values) where TPrimitive : struct, IDomainPrimitive<TPrimitive, TValue> where TValue : notnull

    Creates an array of domain primitives by creating each element from the corresponding raw value in a `System.ReadOnlySpan<T>`.

    values: this System.ReadOnlySpan<TValue>
    The span of raw values to convert.

    Retorna: A new array containing one validated domain primitive for each element in `values`. Never returns `null` but may be empty if `values` is empty.

    Prefer this overload over `ToDomainPrimitiveArray<TPrimitive, TValue>(IEnumerable<TValue>)` when the source is already a span, as it avoids enumeration overhead. This overload is only available on .NET 7 and later. Type parameters: TPrimitive: The domain primitive struct type to create.; TValue: The raw backing value type. Exceptions: DomainPrimitiveValidationException: Any element in `values` fails the domain validation rules

  • methodToDomainPrimitiveList<TPrimitive, TValue>
    public static List<TPrimitive> ToDomainPrimitiveList<TPrimitive, TValue>(this IEnumerable<TValue> values) where TPrimitive : struct, IDomainPrimitive<TPrimitive, TValue> where TValue : notnull

    Creates a `List<T>` of domain primitives by creating each element from the corresponding raw value.

    values: this IEnumerable<TValue>
    The sequence of raw values to convert.

    Retorna: A new `List<T>` containing one validated domain primitive for each element in `values`. Never returns `null` but may be empty if the source sequence is empty.

    Each element is created via `IDomainPrimitive<TSelf, TValue>.Create`, which applies normalization and validation. Creation stops at the first invalid value. Type parameters: TPrimitive: The domain primitive struct type to create.; TValue: The raw backing value type. Exceptions: ArgumentException: An element in `values` fails domain validation rules. The `Exception.InnerException` is a `DomainPrimitiveValidationException` carrying the structured error code and the zero-based element index is included in the exception message; NotSupportedException: The target framework is below .NET 7.0, which does not support static abstract interface members

  • methodToDomainPrimitiveList<TPrimitive, TValue>
    public static List<TPrimitive> ToDomainPrimitiveList<TPrimitive, TValue>(this IEnumerable<TValue> values, Func<TValue, TPrimitive> factory) where TPrimitive : struct where TValue : notnull

    Creates a `List<T>` of domain primitives by invoking `factory` for each raw value.

    values: this IEnumerable<TValue>
    The sequence of raw values to convert.
    factory: Func<TValue, TPrimitive>
    The factory delegate used to construct each domain primitive.

    Retorna: A new `List<T>` containing one domain primitive for each element in `values`.

    This overload is available on all supported platforms, including netstandard2.0, where static abstract interface members are not available. Type parameters: TPrimitive: The domain primitive struct type to create.; TValue: The raw backing value type. Exceptions: ArgumentNullException: `values` or `factory` is `null`; ArgumentException: An element in `values` fails domain validation

class

PrimitiveRangeAttribute

Ensamblado: EricksonLopez.DomainPrimitives.Abstractions
public sealed class PrimitiveRangeAttribute : Attribute
Hereda de: Attribute

Specifies range validation constraints on numeric domain primitives. Use this instead of `RangeAttribute` when your project also references `System.ComponentModel.DataAnnotations` to avoid ambiguous attribute errors.

Notas:

Accepts `double` bounds due to a C# language limitation — `decimal` is not a valid attribute parameter type. For exact decimal ranges, use the `(string, string)` constructor overload (e.g., `[PrimitiveRange("0.00", "1000000.00")]`).

Miembros (10)

  • constructorPrimitiveRangeAttribute
    public PrimitiveRangeAttribute(double min, double max)

    Initializes a new instance of the `PrimitiveRangeAttribute` class with the specified double bounds.

    min: double
    The minimum allowed value (inclusive by default).
    max: double
    The maximum allowed value (inclusive by default).
  • constructorPrimitiveRangeAttribute
    public PrimitiveRangeAttribute(string stringMin, string stringMax)

    Initializes a new instance of the `PrimitiveRangeAttribute` class with the specified string bounds for exact precision.

    stringMin: string
    The minimum bound expressed as a parseable string. Use for exact `decimal` precision.
    stringMax: string
    The maximum bound expressed as a parseable string. Use for exact `decimal` precision.
  • propertyErrorCode
    public string? ErrorCode { get; set; }

    Gets or sets the error code emitted when the range constraint is violated. Defaults to `"RANGE"`.

  • propertyErrorMessage
    public string? ErrorMessage { get; set; }

    Gets or sets the error message emitted when the value is outside the allowed range.

  • propertyMax
    public double Max { get; }

    Gets the maximum allowed value when specified as a `double`. Zero when the string overload is used.

  • propertyMaxExclusive
    public bool MaxExclusive { get; init; }

    Gets or sets a value indicating whether the maximum bound is exclusive. Default: `false` (inclusive).

  • propertyMin
    public double Min { get; }

    Gets the minimum allowed value when specified as a `double`. Zero when the string overload is used.

  • propertyMinExclusive
    public bool MinExclusive { get; init; }

    Gets or sets a value indicating whether the minimum bound is exclusive. Default: `false` (inclusive).

  • propertyStringMax
    public string? StringMax { get; }

    Gets the maximum bound as a string when specified via the string overload; otherwise `null`.

  • propertyStringMin
    public string? StringMin { get; }

    Gets the minimum bound as a string when specified via the string overload; otherwise `null`.

class

QuantityAttribute

Ensamblado: EricksonLopez.DomainPrimitives.Abstractions
public sealed class QuantityAttribute : Attribute
Hereda de: Attribute

Specifies that a struct is a quantity domain primitive. Equivalent to: `[NumericPrimitive<int>] [PrimitiveRange(0, int.MaxValue)]`.

Notas:

Represents a non-negative integer count (units in stock, items ordered, etc.).

Miembros (2)

  • propertyMax
    public int Max { get; init; }

    Gets the maximum quantity (inclusive). Default: `int.MaxValue`.

  • propertyMin
    public int Min { get; init; }

    Gets the minimum quantity (inclusive). Default: 0.

class

QuarterAttribute

Ensamblado: EricksonLopez.DomainPrimitives.Abstractions
public sealed class QuarterAttribute : Attribute
Hereda de: Attribute

Specifies that a struct is a quarter domain primitive.

Miembros (0)

Este tipo declara 0 miembros públicos (por ejemplo, interfaz marcadora o enum/record vacío).

class

RatingAttribute

Ensamblado: EricksonLopez.DomainPrimitives.Abstractions
public sealed class RatingAttribute : Attribute
Hereda de: Attribute

Specifies that a struct is a rating domain primitive. Equivalent to: `[NumericPrimitive<decimal>] [PrimitiveRange(0, 5)]`.

Notas:

Represents a star rating on a 0–5 scale with decimal precision (e.g., 4.5 stars). Adjust `Min`, `Max`, and `Scale` for other rating systems (e.g., 1–10).

Miembros (3)

  • propertyMax
    public double Max { get; init; }

    Gets the maximum rating. Default: 5.

  • propertyMin
    public double Min { get; init; }

    Gets the minimum rating. Default: 0.

  • propertyScale
    public int Scale { get; init; }

    Gets the number of decimal places allowed. Default: 1 (e.g., 4.5). Use 0 for whole-number-only ratings.

class

RegexAttribute

Ensamblado: EricksonLopez.DomainPrimitives.Abstractions
public sealed class RegexAttribute : Attribute
Hereda de: Attribute

Specifies a regular expression pattern that the string value must match.

Miembros (4)

  • constructorRegexAttribute
    public RegexAttribute(string pattern)

    Initializes a new instance of the `RegexAttribute` class with the specified regular expression pattern.

    pattern: string
    The regular expression pattern the value must match.
  • propertyErrorCode
    public string? ErrorCode { get; set; }

    Gets or sets the error code emitted when the pattern is not matched. Defaults to `"FORMAT"`.

  • propertyErrorMessage
    public string? ErrorMessage { get; set; }

    Gets or sets the error message emitted when the value does not match the pattern.

  • propertyPattern
    public string Pattern { get; }

    Gets the regular expression pattern the value must match.

class

ScoreAttribute

Ensamblado: EricksonLopez.DomainPrimitives.Abstractions
public sealed class ScoreAttribute : Attribute
Hereda de: Attribute

Specifies that a struct is a score domain primitive. Equivalent to: `[NumericPrimitive<int>] [PrimitiveRange(0, 100)]`.

Notas:

Represents a generic score on a 0-100 integer scale. For decimal scores or different ranges, use `[NumericPrimitive<T>]` directly.

Miembros (2)

  • propertyMax
    public int Max { get; init; }

    Gets the maximum score (inclusive). Default: 100.

  • propertyMin
    public int Min { get; init; }

    Gets the minimum score (inclusive). Default: 0.

class

SlugAttribute

Ensamblado: EricksonLopez.DomainPrimitives.Abstractions
public sealed class SlugAttribute : Attribute
Hereda de: Attribute

Specifies that a struct is a URL slug domain primitive. Equivalent to: `[StringPrimitive] [Trim] [LowerCase] [Regex(slug-pattern)]`.

Miembros (1)

  • propertyMaxLength
    public int MaxLength { get; init; }

    Gets the maximum length. Default: 200.

class

SmartEnumAttribute<TValue>

Ensamblado: EricksonLopez.DomainPrimitives.Abstractions
public sealed class SmartEnumAttribute<TValue> : Attribute where TValue : notnull
Hereda de: Attribute

Specifies that a struct is a smart enum with a backing value of type `TValue`.

Notas:

Smart enums are type-safe, behavior-rich alternatives to C# `enum` types. They support metadata, exhaustive matching, and parse-from-name/value operations. Define instances as `public static readonly` fields within the type. The source generator discovers them and generates the required infrastructure. Type parameters: TValue: The backing value type for enum members (e.g., `int`, `string`). Example:

[SmartEnum<int>]
public readonly partial record struct OrderStatus
{
    public static readonly OrderStatus Pending = new(0, "Pending");
    public static readonly OrderStatus Shipped = new(1, "Shipped");
    public static readonly OrderStatus Delivered = new(2, "Delivered");
}

Miembros (0)

Este tipo declara 0 miembros públicos (por ejemplo, interfaz marcadora o enum/record vacío).

class

StringPrimitiveAttribute

Ensamblado: EricksonLopez.DomainPrimitives.Abstractions
public sealed class StringPrimitiveAttribute : Attribute
Hereda de: Attribute

Specifies that a struct is a string-backed domain primitive.

Notas:

Use this attribute for string values that need type safety and optional validation/normalization. Combine with validation attributes (`Validation.MinLengthAttribute`, `Validation.MaxLengthAttribute`, `Validation.RegexAttribute`) and normalization attributes (`Normalization.TrimAttribute`, `Normalization.LowerCaseAttribute`) to compose the desired behavior. For domain-specific string types (email, phone, URL), use the shortcut attributes (`EmailAttribute`, `PhoneAttribute`, `UrlAttribute`) which combine `[StringPrimitive]` with appropriate validation and normalization. Example:

[StringPrimitive]
[Trim]
[MinLength(1)]
[MaxLength(100)]
public readonly partial record struct FirstName;

Miembros (0)

Este tipo declara 0 miembros públicos (por ejemplo, interfaz marcadora o enum/record vacío).

class

StrongIdAttribute<TValue>

Ensamblado: EricksonLopez.DomainPrimitives.Abstractions
public sealed class StrongIdAttribute<TValue> : Attribute where TValue : notnull
Hereda de: Attribute

Specifies that a struct is a strongly-typed identifier wrapping `TValue`.

Notas:

The source generator produces a complete strong ID implementation including: factory methods (`Create()`, `TryCreate()`, `Empty`), parsing (`IParsable<TSelf>`, `ISpanParsable<TSelf>`, `IUtf8SpanParsable<TSelf>`), formatting (`IFormattable`, `ISpanFormattable`, `IUtf8SpanFormattable`), comparison, and explicit operators. Supported backing types: `Guid`, `int`, `long`, `string`. Type parameters: TValue: The backing identity type. Example:

[StrongId<Guid>]
public readonly partial record struct CustomerId;

// Usage:
var id = CustomerId.Create(Guid.NewGuid());
var parsed = CustomerId.Parse("a1b2c3d4-e5f6-7a8b-9c0d-1e2f3a4b5c6d", null);
Guid raw = (Guid)id;

Miembros (1)

  • propertyRejectEmpty
    public bool RejectEmpty { get; set; }

    Gets or sets a value indicating whether empty backing values are rejected. When `true`, `Create()` throws and `TryCreate()` returns `false` for empty values (e.g., `Guid.Empty`, `0`, or `""`). Defaults to `true`.

class

TaxRateAttribute

Ensamblado: EricksonLopez.DomainPrimitives.Abstractions
public sealed class TaxRateAttribute : Attribute
Hereda de: Attribute

Specifies that a struct is a tax rate domain primitive. Equivalent to: `[NumericPrimitive<decimal>] [PrimitiveRange(0, 100)]`.

Notas:

Represents a tax rate as a percentage (e.g., 21.0 for 21%). To use a 0–1 decimal fraction instead, set `Max = 1`.

Miembros (2)

  • propertyMax
    public double Max { get; init; }

    Gets the maximum tax rate percentage. Default: 100.

  • propertyMin
    public double Min { get; init; }

    Gets the minimum tax rate percentage. Default: 0.

class

TemperatureAttribute

Ensamblado: EricksonLopez.DomainPrimitives.Abstractions
public sealed class TemperatureAttribute : Attribute
Hereda de: Attribute

Specifies that a struct is a temperature domain primitive. Equivalent to: `[NumericPrimitive<double>] [PrimitiveRange(-273.15, double.MaxValue)]`.

Notas:

Default minimum of -273.15°C corresponds to absolute zero (0 Kelvin). This works for Celsius units. Override `Min` for Fahrenheit or Kelvin.

Miembros (2)

  • propertyMax
    public double Max { get; init; }

    Gets the maximum temperature. Default: `double.MaxValue`.

  • propertyMin
    public double Min { get; init; }

    Gets the minimum temperature. Default: -273.15 (absolute zero in Celsius).

class

TimeRangeAttribute

Ensamblado: EricksonLopez.DomainPrimitives.Abstractions
public sealed class TimeRangeAttribute : Attribute
Hereda de: Attribute

Specifies that a struct is a time range domain primitive. Architectural Guidance: In Domain-Driven Design, when modeling a compound interval with both start and end times and cross-property validation (`Start <= End`), prefer creating a compound `[ValueObject]`.

Miembros (0)

Este tipo declara 0 miembros públicos (por ejemplo, interfaz marcadora o enum/record vacío).

class

TrimAttribute

Ensamblado: EricksonLopez.DomainPrimitives.Abstractions
public sealed class TrimAttribute : Attribute
Hereda de: Attribute

Specifies that leading and trailing whitespace should be trimmed from the string value.

Notas:

Normalization runs before validation. Applied via `string.Trim()`.

Miembros (0)

Este tipo declara 0 miembros públicos (por ejemplo, interfaz marcadora o enum/record vacío).

class

TrimEndAttribute

Ensamblado: EricksonLopez.DomainPrimitives.Abstractions
public sealed class TrimEndAttribute : Attribute
Hereda de: Attribute

Specifies that trailing whitespace should be trimmed from a string domain primitive before validation.

Miembros (0)

Este tipo declara 0 miembros públicos (por ejemplo, interfaz marcadora o enum/record vacío).

class

TrimStartAttribute

Ensamblado: EricksonLopez.DomainPrimitives.Abstractions
public sealed class TrimStartAttribute : Attribute
Hereda de: Attribute

Specifies that leading whitespace should be trimmed from a string domain primitive before validation.

Miembros (0)

Este tipo declara 0 miembros públicos (por ejemplo, interfaz marcadora o enum/record vacío).

class

UpperCaseAttribute

Ensamblado: EricksonLopez.DomainPrimitives.Abstractions
public sealed class UpperCaseAttribute : Attribute
Hereda de: Attribute

Specifies that a string domain primitive should be converted to upper case before validation.

Miembros (0)

Este tipo declara 0 miembros públicos (por ejemplo, interfaz marcadora o enum/record vacío).

class

UrlAttribute

Ensamblado: EricksonLopez.DomainPrimitives.Abstractions
public sealed class UrlAttribute : Attribute
Hereda de: Attribute

Specifies that a struct is a URL domain primitive. Equivalent to: `[StringPrimitive] [Trim]` with `System.Uri` validation.

Miembros (1)

  • propertyAllowedSchemes
    public string[] AllowedSchemes { get; init; }

    Gets the allowed URI schemes. Default: `["https", "http"]`.

class

UsernameAttribute

Ensamblado: EricksonLopez.DomainPrimitives.Abstractions
public sealed class UsernameAttribute : Attribute
Hereda de: Attribute

Specifies that a struct is a username domain primitive. Equivalent to: `[StringPrimitive] [Trim] [Regex(alphanumeric + ._-)]`.

Miembros (2)

  • propertyMaxLength
    public int MaxLength { get; init; }

    Gets the maximum length. Default: 50.

  • propertyMinLength
    public int MinLength { get; init; }

    Gets the minimum length. Default: 3.

class

VINAttribute

Ensamblado: EricksonLopez.DomainPrimitives.Abstractions
public sealed class VINAttribute : Attribute
Hereda de: Attribute

Specifies that a struct is a Vehicle Identification Number (VIN) domain primitive. Equivalent to: `[StringPrimitive] [Trim] [UpperCase] [Regex(vin-pattern)]`.

Miembros (0)

Este tipo declara 0 miembros públicos (por ejemplo, interfaz marcadora o enum/record vacío).

record

ValueObject

Ensamblado: EricksonLopez.DomainPrimitives.Abstractions
public abstract record class ValueObject

Base record class for complex multi-property Value Objects — types defined by their structural equality.

Notas:

A value object has no identity — two value objects are equal if all their components are equal. Value objects must be immutable. By inheriting from this `record class`, the compiler automatically generates `IEquatable<T>.Equals(T)` and `object.GetHashCode` that provide value equality over all properties and fields, with zero boxing allocations. When to use `ValueObject` vs source-generator attributes: **Use case**: **Recommended approach**: - **Single-wrapping primitive (string, int, Guid, decimal, DateOnly...)**: **Source-generator attributes: `[StringPrimitive]`, `[Money]`, `[StrongId]`, etc.**: - **Complex multi-property value object (e.g., Money + Currency, Address)**: **Inherit from `ValueObject` as a `sealed record`**: Important: The source-generated primitives (e.g., `[Money]` generates a `readonly record struct Money`) are independent value types and do not inherit from `ValueObject`. `ValueObject` is a heap-allocated `record class`, while generated primitives are stack-allocated `record struct`s.

// ✅ Correct — complex multi-property value object (use ValueObject base)
public sealed record Money(decimal Amount, string Currency) : ValueObject;

// ✅ Correct — single-wrapping primitive (use source generator attribute)
[Money]
public partial struct ProductPrice;  // generates: readonly partial record struct ProductPrice

Miembros (0)

Este tipo declara 0 miembros públicos (por ejemplo, interfaz marcadora o enum/record vacío).

class

ValueObjectAttribute

Ensamblado: EricksonLopez.DomainPrimitives.Abstractions
public sealed class ValueObjectAttribute : Attribute
Hereda de: Attribute

Specifies that a struct is a composite value object with structural equality across all properties.

Notas:

Unlike single-value domain primitives, a value object can have multiple properties. The source generator produces zero-boxing equality, `GetHashCode`, and formatting based on all public properties. All properties must use `required` and `init` to ensure immutability and complete initialization. Example:

[ValueObject]
public readonly partial record struct Address
{
    public required string Street { get; init; }
    public required string City { get; init; }
    public required string State { get; init; }
    public required string ZipCode { get; init; }
}

Miembros (0)

Este tipo declara 0 miembros públicos (por ejemplo, interfaz marcadora o enum/record vacío).

class

WeekAttribute

Ensamblado: EricksonLopez.DomainPrimitives.Abstractions
public sealed class WeekAttribute : Attribute
Hereda de: Attribute

Specifies that a struct is a week domain primitive.

Miembros (1)

  • propertyIsoWeekNumbering
    public bool IsoWeekNumbering { get; init; }

    Gets a value indicating whether ISO 8601 week numbering is used. Default: `true`.

class

WeightAttribute

Ensamblado: EricksonLopez.DomainPrimitives.Abstractions
public sealed class WeightAttribute : Attribute
Hereda de: Attribute

Specifies that a struct is a weight domain primitive. Equivalent to: `[NumericPrimitive<double>] [PrimitiveRange(0, double.MaxValue)]`.

Notas:

Represents weight in kilograms (SI unit). For other units, use `[NumericPrimitive<double>]` directly.

Miembros (2)

  • propertyMax
    public double Max { get; init; }

    Gets the maximum allowed weight in kg. Default: 1000.

  • propertyMin
    public double Min { get; init; }

    Gets the minimum allowed weight in kg. Default: 0.

EricksonLopez.DomainPrimitives.Advanced#

1
class

PrimitiveBuilder<TPrimitive, TValue>

Ensamblado: EricksonLopez.DomainPrimitives.Abstractions
public sealed class PrimitiveBuilder<TPrimitive, TValue> where TPrimitive : struct, IDomainPrimitive<TPrimitive, TValue> where TValue : notnull

Provides a fluent builder for programmatically validating and creating domain primitive instances with support for additional custom validation rules.

Notas:

This builder allocates heap memory and is not suitable for hot paths. For zero-allocation creation, use `IDomainPrimitive<TSelf, TValue>.Create` or `IDomainPrimitive<TSelf, TValue>.TryCreate` directly. Type parameters: TPrimitive: The domain primitive struct type to build.; TValue: The underlying backing value type.

Miembros (5)

  • methodBuild
    public bool Build(out TPrimitive result)

    Attempts to validate and construct the domain primitive instance without throwing exceptions.

    result: out TPrimitive
    When this method returns `true`, contains the constructed domain primitive instance; otherwise, the default value for `TPrimitive`.

    Retorna: `true` if creation succeeded; otherwise, `false`.

    Exceptions: NotSupportedException: Thrown when the target framework is below .NET 7.0, as static abstract interface members are not supported on earlier runtimes

  • methodBuildOrThrow
    public TPrimitive BuildOrThrow()

    Validates and constructs the domain primitive instance.

    Retorna: A valid domain primitive instance.

    Exceptions: DomainPrimitiveValidationException: Thrown when validation fails or no value was configured via `WithValue`; NotSupportedException: Thrown when the target framework is below .NET 7.0, as static abstract interface members are not supported on earlier runtimes

  • methodFor
    public static PrimitiveBuilder<TPrimitive, TValue> For()

    Creates a new, empty `PrimitiveBuilder<TPrimitive, TValue>` with no value configured.

    Retorna: A new builder instance ready for configuration via `WithValue` and `Must`.

  • methodMust
    public PrimitiveBuilder<TPrimitive, TValue> Must(Func<TValue, bool> predicate, string errorCode, string errorMessage)

    Appends a custom validation rule predicate to the builder pipeline.

    predicate: Func<TValue, bool>
    A predicate function returning `true` if the value is valid.
    errorCode: string
    The error code identifying the failure when validation fails.
    errorMessage: string
    The human-readable description of the error when validation fails.

    Retorna: The builder instance for chaining.

  • methodWithValue
    public PrimitiveBuilder<TPrimitive, TValue> WithValue(TValue value)

    Sets the backing value for the primitive to build.

    value: TValue
    The raw value to configure.

    Retorna: The builder instance for chaining.

EricksonLopez.DomainPrimitives.Analyzers#

14
class

ApiReviewAnalyzer

Ensamblado: EricksonLopez.DomainPrimitives.Analyzers
public sealed class ApiReviewAnalyzer : DiagnosticAnalyzer
Hereda de: DiagnosticAnalyzer

Enforces API surface quality rules on domain primitive types, including API budget limits, missing XML documentation, and invalid factory method names.

Notas:

Reports the following diagnostics: - **DP0014**: API surface budget exceeded. - **DP0015**: Public member missing XML documentation. - **DP0016**: Custom factory method uses a non-standard name.

Miembros (2)

  • methodInitialize
    public override void Initialize(AnalysisContext context)

    Inherits documentation from base type or interface.

    context: AnalysisContext
  • propertySupportedDiagnostics
    public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics { get; }

    Inherits documentation from base type or interface.

class

ApiReviewCodeFixProvider

Ensamblado: EricksonLopez.DomainPrimitives.Analyzers
public sealed class ApiReviewCodeFixProvider : CodeFixProvider
Hereda de: CodeFixProvider

Provides code fixes for `DP0015` (missing XML documentation) and `DP0016` (invalid factory method name) reported by `ApiReviewAnalyzer`.

Notas:

The fix for `DP0015` inserts a skeleton XML ` ` comment. The fix for `DP0016` renames the non-conforming factory method to `Create` across the entire solution using the Roslyn rename service.

Miembros (3)

  • methodGetFixAllProvider
    public override FixAllProvider GetFixAllProvider()

    Inherits documentation from base type or interface.

  • methodRegisterCodeFixesAsync
    public override async Task RegisterCodeFixesAsync(CodeFixContext context)

    Inherits documentation from base type or interface.

    context: CodeFixContext
  • propertyFixableDiagnosticIds
    public override ImmutableArray<string> FixableDiagnosticIds { get; }

    Inherits documentation from base type or interface.

class

AttributeValidationAnalyzer

Ensamblado: EricksonLopez.DomainPrimitives.Analyzers
public sealed class AttributeValidationAnalyzer : DiagnosticAnalyzer
Hereda de: DiagnosticAnalyzer

Validates attribute configurations on domain primitive types, detecting invalid regex patterns, conflicting normalization attributes, and illegal constraint bounds.

Notas:

Reports the following diagnostics: - **DP0004**: Regex pattern is syntactically invalid. - **DP0005**: `[LowerCase]` and `[UpperCase]` used simultaneously. - **DP0006**: Minimum constraint value exceeds maximum. - **DP0017**: Custom exception type specified in `[DomainPrimitivesDefaults]` is invalid.

Miembros (2)

  • methodInitialize
    public override void Initialize(AnalysisContext context)

    Inherits documentation from base type or interface.

    context: AnalysisContext
  • propertySupportedDiagnostics
    public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics { get; }

    Inherits documentation from base type or interface.

class

DuplicatePrimitiveLogicAnalyzer

Ensamblado: EricksonLopez.DomainPrimitives.Analyzers
public sealed class DuplicatePrimitiveLogicAnalyzer : DiagnosticAnalyzer
Hereda de: DiagnosticAnalyzer

Detects domain primitive types that share identical attribute configurations within the same compilation, indicating potential copy-paste duplication of domain concepts.

Notas:

Reports `DP0013` at compile-end for each pair of `readonly partial record struct` types whose attribute signatures are identical. The diagnostic is informational — the types may intentionally share structure but represent distinct concepts, in which case the warning should be suppressed with a justification comment.

Miembros (2)

  • methodInitialize
    public override void Initialize(AnalysisContext context)

    Inherits documentation from base type or interface.

    context: AnalysisContext
  • propertySupportedDiagnostics
    public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics { get; }

    Inherits documentation from base type or interface.

class

MissingValidationAnalyzer

Ensamblado: EricksonLopez.DomainPrimitives.Analyzers
public sealed class MissingValidationAnalyzer : DiagnosticAnalyzer
Hereda de: DiagnosticAnalyzer

Detects domain primitive types that declare no validation rules, ensuring that every primitive enforces at least one invariant to justify its existence.

Notas:

Reports `DP0009` when a `[StringPrimitive]`, `[NumericPrimitive]`, or `[DatePrimitive]` type carries no validation or domain-shortcut attribute. Also reports `DP0009` for `[StrongId<string>]` types that carry no length or format constraint, as an unconstrained string id is semantically equivalent to a plain `string`.

Miembros (2)

  • methodInitialize
    public override void Initialize(AnalysisContext context)

    Inherits documentation from base type or interface.

    context: AnalysisContext
  • propertySupportedDiagnostics
    public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics { get; }

    Inherits documentation from base type or interface.

class

MissingValidationCodeFixProvider

Ensamblado: EricksonLopez.DomainPrimitives.Analyzers
public sealed class MissingValidationCodeFixProvider : CodeFixProvider
Hereda de: CodeFixProvider

Provides a code fix for `DP0009` (missing validation) that inserts a `[NotEmpty]` attribute as a baseline validation guard on the affected primitive.

Miembros (3)

  • methodGetFixAllProvider
    public override FixAllProvider GetFixAllProvider()

    Inherits documentation from base type or interface.

  • methodRegisterCodeFixesAsync
    public override async Task RegisterCodeFixesAsync(CodeFixContext context)

    Inherits documentation from base type or interface.

    context: CodeFixContext
  • propertyFixableDiagnosticIds
    public override ImmutableArray<string> FixableDiagnosticIds { get; }

    Inherits documentation from base type or interface.

class

PrimitiveUsageAnalyzer

Ensamblado: EricksonLopez.DomainPrimitives.Analyzers
public sealed class PrimitiveUsageAnalyzer : DiagnosticAnalyzer
Hereda de: DiagnosticAnalyzer

Detects usage of the default constructor or `default` literal on domain primitive types, where the standard `Create()` factory should be used instead.

Notas:

Reports `DP0007` for any `new PrimitiveType()`, implicit `new()`, `default(PrimitiveType)`, or `default` literal expression that resolves to a type implementing `IDomainPrimitive` or `IStrongId`. Such expressions bypass validation and produce an uninitialized primitive instance.

Miembros (2)

  • methodInitialize
    public override void Initialize(AnalysisContext context)

    Inherits documentation from base type or interface.

    context: AnalysisContext
  • propertySupportedDiagnostics
    public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics { get; }

    Inherits documentation from base type or interface.

class

PrimitiveUsageCodeFixProvider

Ensamblado: EricksonLopez.DomainPrimitives.Analyzers
public sealed class PrimitiveUsageCodeFixProvider : CodeFixProvider
Hereda de: CodeFixProvider

Provides automated code fixes for `DP0007` (avoid uninitialized domain primitives), replacing default or parameterless constructor invocations with appropriate factory methods or sentinels.

Miembros (3)

  • methodGetFixAllProvider
    public override FixAllProvider GetFixAllProvider()

    Inherits documentation from base type or interface.

  • methodRegisterCodeFixesAsync
    public override async Task RegisterCodeFixesAsync(CodeFixContext context)

    Inherits documentation from base type or interface.

    context: CodeFixContext
  • propertyFixableDiagnosticIds
    public override ImmutableArray<string> FixableDiagnosticIds { get; }

    Inherits documentation from base type or interface.

class

PublicConstructorBypassAnalyzer

Ensamblado: EricksonLopez.DomainPrimitives.Analyzers
public sealed class PublicConstructorBypassAnalyzer : DiagnosticAnalyzer
Hereda de: DiagnosticAnalyzer

Detects when a domain primitive type declares a public constructor that can bypass the source-generated validation pipeline.

Notas:

Reports `DP0012` when a `readonly partial record struct` decorated with a domain primitive attribute also declares a `public` constructor. The source generator intentionally generates a `private` constructor to force consumers to use `Create()` or `TryCreate()`. A public constructor bypasses this invariant and allows the creation of unvalidated instances.

Miembros (2)

  • methodInitialize
    public override void Initialize(AnalysisContext context)

    Inherits documentation from base type or interface.

    context: AnalysisContext
  • propertySupportedDiagnostics
    public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics { get; }

    Inherits documentation from base type or interface.

class

StringComparisonAnalyzer

Ensamblado: EricksonLopez.DomainPrimitives.Analyzers
public sealed class StringComparisonAnalyzer : DiagnosticAnalyzer
Hereda de: DiagnosticAnalyzer

Detects incorrect usage of domain primitives in string comparisons and assignments.

Notas:

Reports `DP0010` when a raw `string` is compared to a domain primitive via `==` or `!=`, which bypasses the type system and can produce unexpected results. Reports `DP0011` when a domain primitive is implicitly assigned to a `string` variable, discarding the strong typing without an explicit `.Value` access.

Miembros (2)

  • methodInitialize
    public override void Initialize(AnalysisContext context)

    Inherits documentation from base type or interface.

    context: AnalysisContext
  • propertySupportedDiagnostics
    public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics { get; }

    Inherits documentation from base type or interface.

class

StringComparisonCodeFixProvider

Ensamblado: EricksonLopez.DomainPrimitives.Analyzers
public sealed class StringComparisonCodeFixProvider : CodeFixProvider
Hereda de: CodeFixProvider

Provides code fixes for `DP0010` (string compared with primitive) and `DP0011` (primitive assigned to string) reported by `StringComparisonAnalyzer`.

Notas:

The fix for `DP0011` appends a `.Value` member access to the primitive expression. The fix for `DP0010` appends `.Value` to whichever side of the binary expression is a domain primitive, restoring type-safe comparison semantics.

Miembros (3)

  • methodGetFixAllProvider
    public override FixAllProvider GetFixAllProvider()

    Inherits documentation from base type or interface.

  • methodRegisterCodeFixesAsync
    public override async Task RegisterCodeFixesAsync(CodeFixContext context)

    Inherits documentation from base type or interface.

    context: CodeFixContext
  • propertyFixableDiagnosticIds
    public override ImmutableArray<string> FixableDiagnosticIds { get; }

    Inherits documentation from base type or interface.

class

StructDeclarationAnalyzer

Ensamblado: EricksonLopez.DomainPrimitives.Analyzers
public sealed class StructDeclarationAnalyzer : DiagnosticAnalyzer
Hereda de: DiagnosticAnalyzer

Enforces structural declaration requirements on domain primitive types, ensuring that every decorated type is declared as a `readonly partial record struct`.

Notas:

Reports the following diagnostics: - **DP0001**: Type is not `partial`. - **DP0002**: Type is not `readonly`. - **DP0003**: Type is not a `record struct`.

Miembros (2)

  • methodInitialize
    public override void Initialize(AnalysisContext context)

    Inherits documentation from base type or interface.

    context: AnalysisContext
  • propertySupportedDiagnostics
    public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics { get; }

    Inherits documentation from base type or interface.

class

StructDeclarationCodeFixProvider

Ensamblado: EricksonLopez.DomainPrimitives.Analyzers
public sealed class StructDeclarationCodeFixProvider : CodeFixProvider
Hereda de: CodeFixProvider

Provides code fixes for structural declaration diagnostics (DP0001, DP0002, DP0003) that automatically add the `partial`, `readonly`, or `record struct` modifiers to non-conforming domain primitive types.

Miembros (3)

  • methodGetFixAllProvider
    public override FixAllProvider GetFixAllProvider()

    Inherits documentation from base type or interface.

  • methodRegisterCodeFixesAsync
    public override async Task RegisterCodeFixesAsync(CodeFixContext context)

    Inherits documentation from base type or interface.

    context: CodeFixContext
  • propertyFixableDiagnosticIds
    public override ImmutableArray<string> FixableDiagnosticIds { get; }

    Inherits documentation from base type or interface.

class

ValueObjectAnalyzer

Ensamblado: EricksonLopez.DomainPrimitives.Analyzers
public sealed class ValueObjectAnalyzer : DiagnosticAnalyzer
Hereda de: DiagnosticAnalyzer

Enforces immutability on Value Objects by requiring that all public instance properties declare an `init` accessor rather than `set`.

Notas:

Reports `DP0008` for each public, non-static property on a `[ValueObject]` record struct or a type inheriting from `ValueObject` that declares a mutable `set` accessor. Replace `set` with `init` (and `required` in C# 11+) to satisfy the rule.

Miembros (2)

  • methodInitialize
    public override void Initialize(AnalysisContext context)

    Inherits documentation from base type or interface.

    context: AnalysisContext
  • propertySupportedDiagnostics
    public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics { get; }

    Inherits documentation from base type or interface.

EricksonLopez.DomainPrimitives.AspNetCore#

4
class

DomainPrimitiveModelBinder<T>

Ensamblado: EricksonLopez.DomainPrimitives.AspNetCore
public sealed class DomainPrimitiveModelBinder<T> : IModelBinder
Implementa: IModelBinder

Model binder for domain primitives that seamlessly binds values from HTTP route, query, or form parameters.

Notas:

Type parameters: T: The domain primitive type.

Miembros (1)

  • methodBindModelAsync
    public Task BindModelAsync(ModelBindingContext bindingContext)

    Inherits documentation from base type or interface.

    bindingContext: ModelBindingContext
class

DomainPrimitiveValidationAttribute<TPrimitive, TValue>

Ensamblado: EricksonLopez.DomainPrimitives.AspNetCore
public sealed class DomainPrimitiveValidationAttribute<TPrimitive, TValue> : ValidationAttribute where TPrimitive : struct, IDomainPrimitive<TPrimitive, TValue> where TValue : notnull
Hereda de: ValidationAttribute

Validates a raw value as a domain primitive using the primitive's built-in `TryCreate` validation logic.

Notas:

Apply this attribute to properties in DTOs or request/response models:

public class CreateProductRequest
{
    [DomainPrimitiveValidation<ProductName, string>]
    public string Name { get; set; }

    [DomainPrimitiveValidation<ProductPrice, decimal>]
    public decimal Price { get; set; }
}

This enables domain primitive validation to participate in ASP.NET Core's standard model validation pipeline without requiring manual controller code. Type parameters: TPrimitive: The domain primitive type to validate against.; TValue: The backing value type of the domain primitive.

Miembros (0)

Este tipo declara 0 miembros públicos (por ejemplo, interfaz marcadora o enum/record vacío).

class

DomainPrimitiveValidator

Ensamblado: EricksonLopez.DomainPrimitives.AspNetCore
public static class DomainPrimitiveValidator

Provides DataAnnotations / `IValidatableObject` integration for domain primitives so they participate in ASP.NET Core's model validation pipeline via `ModelValidator`.

Notas:

Usage — wrap your primitive in a DTO that implements `IValidatableObject`:

public record CreateOrderRequest(string CustomerId, decimal Amount) : IValidatableObject
{
    public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
        => DomainPrimitiveValidator.Validate<CustomerId, string>(CustomerId, nameof(CustomerId))
            .Concat(DomainPrimitiveValidator.Validate<OrderAmount, decimal>(Amount, nameof(Amount)));
}

Alternatively, validate a domain primitive directly in a custom `ValidationAttribute`:

[DomainPrimitiveValidation<CustomerId, string>]
public string RawCustomerId { get; set; }

Miembros (2)

  • methodValidate<TPrimitive, TValue>
    public static IEnumerable<ValidationResult> Validate<TPrimitive, TValue>(TValue rawValue, string memberName) where TPrimitive : struct, IDomainPrimitive<TPrimitive, TValue> where TValue : notnull

    Validates a raw value as a domain primitive and returns `ValidationResult`s compatible with the DataAnnotations model validation pipeline.

    rawValue: TValue
    The raw value to validate.
    memberName: string
    The member name to associate with any validation errors (used for `ValidationResult.MemberNames`).

    Retorna: An empty sequence if validation succeeds; a sequence containing one `ValidationResult` per validation error if it fails.

    Type parameters: TPrimitive: The target domain primitive type.; TValue: The backing value type.

  • methodValidateSingle<TPrimitive, TValue>
    public static ValidationResult? ValidateSingle<TPrimitive, TValue>(TValue rawValue, string memberName) where TPrimitive : struct, IDomainPrimitive<TPrimitive, TValue> where TValue : notnull

    Validates a raw value as a domain primitive and returns a single `ValidationResult` or `ValidationResult.Success` if validation passes.

    rawValue: TValue
    The raw value to validate.
    memberName: string
    The member name to associate with any validation error.

    Retorna: `ValidationResult.Success` if validation passes; a `ValidationResult` describing the first validation failure otherwise.

    Type parameters: TPrimitive: The target domain primitive type.; TValue: The backing value type.

class

DomainPrimitivesMvcBuilderExtensions

Ensamblado: EricksonLopez.DomainPrimitives.AspNetCore
public static class DomainPrimitivesMvcBuilderExtensions

Extensions for registering domain primitive model binders and routing conventions in ASP.NET Core MVC.

Miembros (3)

  • methodAddDomainPrimitivesModelBinding
    public static IServiceCollection AddDomainPrimitivesModelBinding(this IServiceCollection services)

    Adds domain primitive model binding to the service collection.

    services: this IServiceCollection
    The service collection.

    Retorna: The service collection for chaining.

  • methodAddDomainPrimitivesModelBinding
    public static MvcOptions AddDomainPrimitivesModelBinding(this MvcOptions options)

    Adds custom model binder support for domain primitives to MVC options.

    options: this MvcOptions
    The `MvcOptions` instance to configure.

    Retorna: The same `MvcOptions` instance for chaining additional configuration.

  • methodRemoveGuidRouteConstraints
    public static MvcOptions RemoveGuidRouteConstraints(this MvcOptions options)

    Registers `RemoveGuidRouteConstraintConvention` on `options` if not already present.

    options: this MvcOptions
    The `MvcOptions` instance to configure.

    Retorna: The same `MvcOptions` instance for chaining.

EricksonLopez.DomainPrimitives.AspNetCore.Routing#

1
class

RemoveGuidRouteConstraintConvention

Ensamblado: EricksonLopez.DomainPrimitives.AspNetCore
public sealed partial class RemoveGuidRouteConstraintConvention : IApplicationModelConvention
Implementa: IApplicationModelConvention

ASP.NET Core `IApplicationModelConvention` that strips `:guid` inline route constraints from attribute route templates so syntactically invalid UUID route segments reach model binding and deterministically return `400 Bad Request` ProblemDetails instead of falling through as `404 Not Found`.

Miembros (1)

  • methodApply
    public void Apply(ApplicationModel application)

    Inherits documentation from base type or interface.

    application: ApplicationModel

EricksonLopez.DomainPrimitives.Dapper#

1
class

DomainPrimitiveTypeHandler<TPrimitive, TValue>

Ensamblado: EricksonLopez.DomainPrimitives.Dapper
public class DomainPrimitiveTypeHandler<TPrimitive, TValue> : global::Dapper.SqlMapper.TypeHandler<TPrimitive> where TPrimitive : struct, IDomainPrimitive<TPrimitive, TValue> where TValue : notnull
Hereda de: global::Dapper.SqlMapper.TypeHandler<TPrimitive>

Provides a base Dapper `SqlMapper.TypeHandler<T>` that maps domain primitives to and from database column values using the primitive's backing value.

Notas:

Type parameters: TPrimitive: The domain primitive struct type to handle.; TValue: The backing value type that maps to the database column type.

Miembros (2)

  • methodParse
    public override TPrimitive Parse(object value)

    Inherits documentation from base type or interface.

    value: object
  • methodSetValue
    public override void SetValue(IDbDataParameter parameter, TPrimitive value)

    Inherits documentation from base type or interface.

    parameter: IDbDataParameter
    value: TPrimitive

EricksonLopez.DomainPrimitives.Diagnostics#

6
class

DomainPrimitiveEventSource

Ensamblado: EricksonLopez.DomainPrimitives
public static class DomainPrimitiveEventSource

Provides a static event source for consuming domain primitive validation events without requiring Dependency Injection.

Notas:

Subscribe to `OnValidationFailed` to route validation failure events to any sink (e.g., `ILogger`, metrics, structured logging) without coupling domain primitives to DI infrastructure. Provided by `EricksonLopez.DomainPrimitives` (Core package) since v1.0.0.

Miembros (1)

  • eventOnValidationFailed
    public static event EventHandler<ValidationFailureEventArgs>? OnValidationFailed

    Occurs when a domain primitive fails validation.

    Invoked from the validation pipeline. Subscribe once during application startup to forward events to `ILogger`, metrics, or other observability sinks. The event sender is always `null`.

class

DomainPrimitivesDiagnostics

Ensamblado: EricksonLopez.DomainPrimitives
public static class DomainPrimitivesDiagnostics

Provides `DiagnosticListener` integration and OpenTelemetry metrics for domain primitives.

Notas:

Provides `DiagnosticListener` and `Meter` integration as part of `EricksonLopez.DomainPrimitives` (Core package). Abstractions contains only: attributes, marker interfaces, and `PrimitiveError`. This separation has been in place since v1.0.0.

Miembros (5)

  • methodWriteValidationFailure
    public static void WriteValidationFailure(string primitiveName, string errorType, string errorMessage)

    Writes a validation failure event to the `DiagnosticListener` and increments the failure counter via `DomainPrimitiveEventSource.OnValidationFailed`.

    primitiveName: string
    The name of the domain primitive type that failed validation.
    errorType: string
    The error code identifying the failure category (e.g., `"FORMAT"`).
    errorMessage: string
    The human-readable description of the validation failure.
  • methodWriteValidationSuccess
    public static void WriteValidationSuccess(string primitiveName)

    Writes a validation success event to the `DiagnosticListener` if any listener is subscribed.

    primitiveName: string
    The name of the domain primitive type that was successfully validated.
  • fieldListenerName
    public static readonly string ListenerName

    Gets the name of the `DiagnosticListener` for events.

  • fieldMeter
    public static readonly Meter Meter

    Gets the `Meter` for domain primitive metrics.

  • fieldSource
    public static readonly DiagnosticListener Source

    Gets the `DiagnosticListener` instance that emits events.

record

DomainPrimitivesDiagnostics.ValidationFailurePayload

Ensamblado: EricksonLopez.DomainPrimitives
public readonly record struct ValidationFailurePayload(string PrimitiveName, string ErrorType, string ErrorMessage)

Represents payload carried by a validation failure diagnostic event.

Miembros (4)

  • constructorValidationFailurePayload
    public ValidationFailurePayload(string PrimitiveName, string ErrorType, string ErrorMessage)

    Initializes a new instance of ValidationFailurePayload.

    PrimitiveName: string
    The name of the domain primitive type that failed validation (e.g., `"EmailAddress"`).
    ErrorType: string
    The error code identifying the failure category (e.g., `"FORMAT"`, `"LENGTH"`).
    ErrorMessage: string
    The human-readable description of the validation failure.
  • propertyErrorMessage
    public string ErrorMessage { get; init; }

    The human-readable description of the validation failure.

  • propertyErrorType
    public string ErrorType { get; init; }

    The error code identifying the failure category (e.g., `"FORMAT"`, `"LENGTH"`).

  • propertyPrimitiveName
    public string PrimitiveName { get; init; }

    The name of the domain primitive type that failed validation (e.g., `"EmailAddress"`).

record

DomainPrimitivesDiagnostics.ValidationSuccessPayload

Ensamblado: EricksonLopez.DomainPrimitives
public readonly record struct ValidationSuccessPayload(string PrimitiveName)

Represents payload carried by a validation success diagnostic event.

Miembros (2)

  • constructorValidationSuccessPayload
    public ValidationSuccessPayload(string PrimitiveName)

    Initializes a new instance of ValidationSuccessPayload.

    PrimitiveName: string
    The name of the domain primitive type that was successfully validated (e.g., `"EmailAddress"`).
  • propertyPrimitiveName
    public string PrimitiveName { get; init; }

    The name of the domain primitive type that was successfully validated (e.g., `"EmailAddress"`).

class

DomainPrimitivesMetrics

Ensamblado: EricksonLopez.DomainPrimitives
public static class DomainPrimitivesMetrics

Provides OpenTelemetry metrics for Domain Primitives, specifically tracking validation success and failure rates.

Notas:

These metrics are provided by `EricksonLopez.DomainPrimitives` (Core package). Abstractions contains only: attributes, marker interfaces, and `PrimitiveError`. This separation has been in place since v1.0.0.

Miembros (5)

  • methodRecordCreation
    public static void RecordCreation(string primitiveName)

    Records the successful creation of a domain primitive instance.

    primitiveName: string
    The name of the primitive type.
  • methodRecordValidationFailure
    public static void RecordValidationFailure(string primitiveName, string errorType, string errorMessage)

    Records a validation failure for a domain primitive.

    primitiveName: string
    The name of the primitive type.
    errorType: string
    The type of error (e.g. 'Format', 'Length').
    errorMessage: string
    The detailed error message.
  • methodRecordValidationSuccess
    public static void RecordValidationSuccess(string primitiveName)

    Records a successful validation of a domain primitive.

    primitiveName: string
    The name of the primitive type (e.g. 'EmailAddress').
  • propertyIsEnabled
    public static bool IsEnabled { get; set; }

    Gets or sets a value indicating whether metrics collection is globally active. Default: `true`.

  • fieldMeterName
    public static readonly string MeterName

    Gets the name of the `Metrics.Meter` for domain primitive metrics.

record

ValidationFailureEventArgs

Ensamblado: EricksonLopez.DomainPrimitives
public readonly record struct ValidationFailureEventArgs(string PrimitiveName, string ErrorType, string ErrorMessage)

Represents event arguments describing a domain primitive validation failure.

Miembros (4)

  • constructorValidationFailureEventArgs
    public ValidationFailureEventArgs(string PrimitiveName, string ErrorType, string ErrorMessage)

    Initializes a new instance of ValidationFailureEventArgs.

    PrimitiveName: string
    The name of the domain primitive type that failed validation (e.g., `"EmailAddress"`).
    ErrorType: string
    The error code identifying the failure category (e.g., `"FORMAT"`, `"LENGTH"`).
    ErrorMessage: string
    The human-readable description of the validation failure.
  • propertyErrorMessage
    public string ErrorMessage { get; init; }

    The human-readable description of the validation failure.

  • propertyErrorType
    public string ErrorType { get; init; }

    The error code identifying the failure category (e.g., `"FORMAT"`, `"LENGTH"`).

  • propertyPrimitiveName
    public string PrimitiveName { get; init; }

    The name of the domain primitive type that failed validation (e.g., `"EmailAddress"`).

EricksonLopez.DomainPrimitives.Financial#

3
enum

AmortizationMode

Ensamblado: EricksonLopez.DomainPrimitives
public enum AmortizationMode

Specifies the period distribution mode for financial amortization schedules.

Miembros (2)

  • fieldLinear
    Linear = 0

    Distributes the principal equally across monthly periods, reconciling residual rounding differences in the final period.

  • fieldProportional
    Proportional = 1

    Distributes the principal proportionally to exact calendar days within each period, reconciling residual rounding differences in the final period.

class

AmortizationScheduleCalculator

Ensamblado: EricksonLopez.DomainPrimitives
public static class AmortizationScheduleCalculator

Pure IFRS/GAAP financial amortization schedule calculator supporting linear monthly and proportional exact-day allocations with deterministic final-period residual penny reconciliation (`Sum(Amount) == principal`).

Miembros (3)

  • methodTryCalculate
    public static bool TryCalculate(decimal principal, DateOnly startDate, DateOnly endDate, AmortizationMode mode, out IReadOnlyList<AmortizationSlice> schedule, out PrimitiveError error, int decimals = 2)

    Calculates an amortization schedule between `startDate` and `endDate` using the specified `mode`.

    principal: decimal
    The positive principal amount to amortize.
    startDate: DateOnly
    The inclusive start date of the amortization window.
    endDate: DateOnly
    The inclusive end date of the amortization window.
    mode: AmortizationMode
    The amortization distribution mode.
    schedule: out IReadOnlyList<AmortizationSlice>
    When successful, receives the immutable ordered list of `AmortizationSlice` entries.
    error: out PrimitiveError
    When validation fails, receives the structured `PrimitiveError`; otherwise `PrimitiveError.None`.
    decimals: int
    The decimal rounding scale (0–6, defaults to 2).

    Retorna: `true` if the schedule was computed; otherwise `false`.

  • methodTryCalculateLinear
    public static bool TryCalculateLinear(decimal principal, int months, DateOnly startDate, out IReadOnlyList<AmortizationSlice> schedule, out PrimitiveError error, int decimals = 2)

    Calculates a linear (equal monthly) amortization schedule across `months` periods starting at `startDate`.

    principal: decimal
    The positive principal amount to amortize.
    months: int
    The number of monthly periods (must be between 1 and 1200).
    startDate: DateOnly
    The start date of the first period.
    schedule: out IReadOnlyList<AmortizationSlice>
    When successful, receives the immutable ordered list of `AmortizationSlice` entries.
    error: out PrimitiveError
    When validation fails, receives the structured `PrimitiveError`; otherwise `PrimitiveError.None`.
    decimals: int
    The decimal rounding scale (0–6, defaults to 2).

    Retorna: `true` if the schedule was computed; otherwise `false`.

  • methodTryCalculateProportional
    public static bool TryCalculateProportional(decimal principal, DateOnly startDate, DateOnly endDate, out IReadOnlyList<AmortizationSlice> schedule, out PrimitiveError error, int decimals = 2)

    Calculates a proportional exact-day amortization schedule between `startDate` and `endDate`.

    principal: decimal
    The positive principal amount to amortize.
    startDate: DateOnly
    The inclusive start date of the amortization window.
    endDate: DateOnly
    The inclusive end date of the amortization window.
    schedule: out IReadOnlyList<AmortizationSlice>
    When successful, receives the immutable ordered list of `AmortizationSlice` entries.
    error: out PrimitiveError
    When validation fails, receives the structured `PrimitiveError`; otherwise `PrimitiveError.None`.
    decimals: int
    The decimal rounding scale (0–6, defaults to 2).

    Retorna: `true` if the schedule was computed; otherwise `false`.

record

AmortizationSlice

Ensamblado: EricksonLopez.DomainPrimitives
public readonly record struct AmortizationSlice

Represents an immutable single-period allocation slice within a financial amortization schedule.

Miembros (9)

  • propertyAccumulatedAmount
    public decimal AccumulatedAmount { get; }

    Gets the cumulative amortized amount up to and including this period.

  • propertyAmount
    public decimal Amount { get; }

    Gets the amortized amount allocated to this period.

  • propertyDaysInPeriod
    public int DaysInPeriod { get; }

    Gets the number of calendar days covered by this slice.

  • propertyPeriodEnd
    public DateOnly PeriodEnd { get; }

    Gets the inclusive end date of this amortization slice.

  • propertyPeriodMonth
    public int PeriodMonth { get; }

    Gets the calendar month (1–12) of the period.

  • propertyPeriodNumber
    public int PeriodNumber { get; }

    Gets the one-based sequential period index within the schedule.

  • propertyPeriodStart
    public DateOnly PeriodStart { get; }

    Gets the inclusive start date of this amortization slice.

  • propertyPeriodYear
    public int PeriodYear { get; }

    Gets the calendar year of the period.

  • propertyRemainingAmount
    public decimal RemainingAmount { get; }

    Gets the remaining unamortized balance after this period.

EricksonLopez.DomainPrimitives.NewtonsoftJson#

4
class

DomainPrimitiveNewtonsoftJsonConverter<TPrimitive, TValue>

Ensamblado: EricksonLopez.DomainPrimitives.NewtonsoftJson
public class DomainPrimitiveNewtonsoftJsonConverter<TPrimitive, TValue> : JsonConverter<TPrimitive> where TPrimitive : struct
Hereda de: JsonConverter<TPrimitive>

Provides a strongly typed Newtonsoft.Json `JsonConverter<T>` for domain primitives.

Notas:

Type parameters: TPrimitive: The domain primitive type.; TValue: The underlying value type.

Miembros (2)

  • methodReadJson
    public override TPrimitive ReadJson(JsonReader reader, Type objectType, TPrimitive existingValue, bool hasExistingValue, JsonSerializer serializer)

    Inherits documentation from base type or interface.

    reader: JsonReader
    objectType: Type
    existingValue: TPrimitive
    hasExistingValue: bool
    serializer: JsonSerializer
  • methodWriteJson
    public override void WriteJson(JsonWriter writer, TPrimitive value, JsonSerializer serializer)

    Inherits documentation from base type or interface.

    writer: JsonWriter
    value: TPrimitive
    serializer: JsonSerializer
class

DomainPrimitiveUniversalNewtonsoftJsonConverter

Ensamblado: EricksonLopez.DomainPrimitives.NewtonsoftJson
public class DomainPrimitiveUniversalNewtonsoftJsonConverter : JsonConverter
Hereda de: JsonConverter

Converts any domain primitive type using a non-generic Newtonsoft.Json `JsonConverter`.

Miembros (3)

  • methodCanConvert
    public override bool CanConvert(Type objectType)

    Inherits documentation from base type or interface.

    objectType: Type
  • methodReadJson
    public override object? ReadJson(JsonReader reader, Type objectType, object? existingValue, JsonSerializer serializer)

    Inherits documentation from base type or interface.

    reader: JsonReader
    objectType: Type
    existingValue: object?
    serializer: JsonSerializer
  • methodWriteJson
    public override void WriteJson(JsonWriter writer, object? value, JsonSerializer serializer)

    Inherits documentation from base type or interface.

    writer: JsonWriter
    value: object?
    serializer: JsonSerializer
class

DomainPrimitivesContractResolver

Ensamblado: EricksonLopez.DomainPrimitives.NewtonsoftJson
public class DomainPrimitivesContractResolver : DefaultContractResolver
Hereda de: DefaultContractResolver

Resolves contracts by automatically attaching domain primitive JSON converters to all types decorating or implementing domain primitives.

Miembros (0)

Este tipo declara 0 miembros públicos (por ejemplo, interfaz marcadora o enum/record vacío).

class

NewtonsoftJsonExtensions

Ensamblado: EricksonLopez.DomainPrimitives.NewtonsoftJson
public static class NewtonsoftJsonExtensions

Extension methods for configuring Newtonsoft.Json with EricksonLopez.DomainPrimitives converters.

Miembros (2)

  • methodAddDomainPrimitives
    public static JsonSerializer AddDomainPrimitives(this JsonSerializer serializer)

    Adds the universal domain primitive JSON converter to the serializer.

    serializer: this JsonSerializer
    The `JsonSerializer` instance.

    Retorna: The same `JsonSerializer` for chaining.

  • methodAddDomainPrimitives
    public static JsonSerializerSettings AddDomainPrimitives(this JsonSerializerSettings settings)

    Adds the universal domain primitive JSON converter to the serializer settings.

    settings: this JsonSerializerSettings
    The `JsonSerializerSettings` instance.

    Retorna: The same `JsonSerializerSettings` for chaining.

EricksonLopez.DomainPrimitives.Testing#

10
class

DomainPrimitiveAssertionsExtensions

Ensamblado: EricksonLopez.DomainPrimitives.Testing
public static class DomainPrimitiveAssertionsExtensions

Provides FluentAssertions extension methods for asserting on domain primitive creation results and instances.

Miembros (7)

  • methodHavePrimitiveValue<TPrimitive, TValue>
    public static AndConstraint<ObjectAssertions> HavePrimitiveValue<TPrimitive, TValue>(this ObjectAssertions assertions, TValue expectedValue) where TPrimitive : struct, IDomainPrimitive<TPrimitive, TValue> where TValue : notnull

    Validates that the domain primitive holds the expected backing value via its `Value` property.

    assertions: this ObjectAssertions
    The FluentAssertions `ObjectAssertions` context.
    expectedValue: TValue
    The backing value the primitive is expected to hold.

    Retorna: An `AndConstraint<T>` for chaining further assertions.

    Type parameters: TPrimitive: The domain primitive type.; TValue: The backing value type.

  • methodShouldBeValidPrimitive<TPrimitive, TValue>
    public static AndConstraint<ObjectAssertions> ShouldBeValidPrimitive<TPrimitive, TValue>(this ObjectAssertions assertions) where TPrimitive : struct, IDomainPrimitive<TPrimitive, TValue> where TValue : notnull

    Validates that the subject value can be successfully converted to the specified domain primitive type.

    assertions: this ObjectAssertions
    The FluentAssertions `ObjectAssertions` context, where the subject must be of type `TValue`.

    Retorna: An `AndConstraint<T>` for chaining further assertions.

    Type parameters: TPrimitive: The domain primitive type.; TValue: The backing value type.

  • methodShouldFailCreationWith<TPrimitive, TValue>
    public static void ShouldFailCreationWith<TPrimitive, TValue>(TValue value, string errorCode) where TPrimitive : struct, IDomainPrimitive<TPrimitive, TValue> where TValue : notnull

    Validates that creating a domain primitive from the given value fails with a specific error code.

    value: TValue
    The value expected to fail validation.
    errorCode: string
    The error code the thrown exception must contain.

    Type parameters: TPrimitive: The domain primitive type.; TValue: The backing value type.

  • methodShouldHaveValidationPrimitiveError<TPrimitive, TValue>
    public static AndConstraint<ObjectAssertions> ShouldHaveValidationPrimitiveError<TPrimitive, TValue>(this ObjectAssertions assertions, string errorCode) where TPrimitive : struct, IDomainPrimitive<TPrimitive, TValue> where TValue : notnull

    Validates that the subject value fails to be converted to the specified domain primitive type and that the thrown exception carries the expected error code.

    assertions: this ObjectAssertions
    The FluentAssertions `ObjectAssertions` context, where the subject must be of type `TValue`.
    errorCode: string
    The `DomainPrimitiveValidationException.Error` code that the validation failure must produce.

    Retorna: An `AndConstraint<T>` for chaining further assertions.

    Type parameters: TPrimitive: The domain primitive type.; TValue: The backing value type.

  • methodShouldSucceedCreation<TPrimitive, TValue>
    public static TPrimitive ShouldSucceedCreation<TPrimitive, TValue>(TValue value) where TPrimitive : struct, IDomainPrimitive<TPrimitive, TValue> where TValue : notnull

    Validates that creating a domain primitive from the given value succeeds and returns the created primitive.

    value: TValue
    The value expected to pass validation.

    Retorna: The created domain primitive for further assertions.

    Type parameters: TPrimitive: The domain primitive type.; TValue: The backing value type.

  • methodThrowDomainPrimitiveException
    public static ExceptionAssertions<DomainPrimitiveValidationException> ThrowDomainPrimitiveException(this ActionAssertions assertions)

    Validates that the action throws a `DomainPrimitiveValidationException`.

    assertions: this ActionAssertions
    The FluentAssertions `ActionAssertions` context.

    Retorna: An `ExceptionAssertions<T>` for inspecting the thrown exception.

  • methodThrowDomainPrimitiveExceptionWithPrimitiveErrorCode
    public static ExceptionAssertions<DomainPrimitiveValidationException> ThrowDomainPrimitiveExceptionWithPrimitiveErrorCode(this ActionAssertions assertions, string errorCode)

    Validates that the action throws a `DomainPrimitiveValidationException` containing a specific error code.

    assertions: this ActionAssertions
    The FluentAssertions `ActionAssertions` context.
    errorCode: string
    The error code that the exception message must contain.

    Retorna: An `ExceptionAssertions<T>` for chaining further exception assertions.

class

DomainPrimitiveFakeFactory

Ensamblado: EricksonLopez.DomainPrimitives.Testing
public static partial class DomainPrimitiveFakeFactory

Provides deterministic fake test data for domain primitives.

Notas:

Unlike random data generators (e.g., Bogus, AutoFixture), `DomainPrimitiveFakeFactory` returns deterministic values to ensure reproducible tests. All valid values are real-world representative samples. Invalid values are carefully chosen to cover boundary conditions and common mistake patterns.

Miembros (0)

Este tipo declara 0 miembros públicos (por ejemplo, interfaz marcadora o enum/record vacío).

class

DomainPrimitiveFakeFactory.Dates

Ensamblado: EricksonLopez.DomainPrimitives.Testing
public static class Dates

Provides deterministic fake test data for date-based domain primitives.

Miembros (10)

  • propertyFutureDate
    public static DateOnly FutureDate { get; }

    Gets a future date (5 years ahead) for expiration date testing.

  • propertyInvalidBusinessDates
    public static List<DateOnly> InvalidBusinessDates { get; }

    Gets invalid business dates (weekends) for testing.

  • propertyInvalidExpirationDates
    public static List<DateOnly> InvalidExpirationDates { get; }

    Gets a set of invalid expiration dates (in the past) for negative testing.

  • propertyInvalidFiscalYears
    public static IReadOnlyList<int> InvalidFiscalYears { get; }

    Gets invalid fiscal years for testing.

  • propertyPastDate
    public static DateOnly PastDate { get; }

    Gets a past date (5 years ago) for past date testing.

  • propertyToday
    public static DateOnly Today { get; }

    Gets current date in UTC for date-based testing.

    Timezone note: Always uses `DateTime.UtcNow` (UTC), not the local system clock. This ensures consistent behavior across CI runners in different timezones. If your domain model uses local time, be aware that date-boundary tests (e.g., "today is valid", "yesterday is invalid") may behave differently if evaluated near midnight UTC.

  • propertyValidBirthDate
    public static DateOnly ValidBirthDate { get; }

    Gets a valid birth date for deterministic testing (30 years in the past, UTC).

    This is a live-computed property (not static readonly). Each call returns 30 years before the current UTC date. For snapshot-based tests, capture the value once and reuse it.

  • propertyValidBusinessDates
    public static List<DateOnly> ValidBusinessDates { get; }

    Gets valid business dates (Monday-Friday) for testing, computed dynamically from today.

    Dates are computed at class initialization time to avoid clock drift within a single test run.

  • propertyValidExpirationDates
    public static List<DateOnly> ValidExpirationDates { get; }

    Gets a set of valid future expiration dates for testing.

  • propertyValidFiscalYears
    public static IReadOnlyList<int> ValidFiscalYears { get; }

    Gets valid fiscal years for testing.

class

DomainPrimitiveFakeFactory.Identifiers

Ensamblado: EricksonLopez.DomainPrimitives.Testing
public static class Identifiers

Provides deterministic fake test data for identifier-based domain primitives.

Miembros (4)

  • propertyInvalidGuidStrings
    public static IReadOnlyList<string> InvalidGuidStrings { get; }

    Gets a set of invalid GUID strings for negative testing.

  • propertyValidGuid
    public static Guid ValidGuid { get; }

    Gets the first valid GUID — convenient for single-value tests.

  • propertyValidGuidStrings
    public static IReadOnlyList<string> ValidGuidStrings { get; }

    Gets a set of GUID strings for testing string-based parsing.

  • propertyValidGuids
    public static IReadOnlyList<Guid> ValidGuids { get; }

    Gets a set of known non-empty GUIDs for testing.

class

DomainPrimitiveFakeFactory.Numerics

Ensamblado: EricksonLopez.DomainPrimitives.Testing
public static class Numerics

Provides deterministic fake test data for numeric domain primitives.

Miembros (30)

  • propertyInvalidAges
    public static IReadOnlyList<int> InvalidAges { get; }

    Gets a set of invalid age values for negative testing.

  • propertyInvalidDiscounts
    public static IReadOnlyList<decimal> InvalidDiscounts { get; }

    Gets a set of invalid discount percentages for negative testing.

  • propertyInvalidDistances
    public static IReadOnlyList<double> InvalidDistances { get; }

    Gets a set of invalid distance values for negative testing.

  • propertyInvalidHeights
    public static IReadOnlyList<double> InvalidHeights { get; }

    Gets a set of invalid height values for negative testing.

  • propertyInvalidLatitudes
    public static IReadOnlyList<double> InvalidLatitudes { get; }

    Gets a set of invalid latitude values for negative testing.

  • propertyInvalidLongitudes
    public static IReadOnlyList<double> InvalidLongitudes { get; }

    Gets a set of invalid longitude values for negative testing.

  • propertyInvalidMoneyAmounts
    public static IReadOnlyList<decimal> InvalidMoneyAmounts { get; }

    Gets a set of invalid monetary amounts (negative) for negative testing.

  • propertyInvalidPercentages
    public static IReadOnlyList<decimal> InvalidPercentages { get; }

    Gets a set of invalid percentages for negative testing.

  • propertyInvalidPrices
    public static IReadOnlyList<decimal> InvalidPrices { get; }

    Gets a set of invalid prices for negative testing.

  • propertyInvalidQuantities
    public static IReadOnlyList<int> InvalidQuantities { get; }

    Gets a set of invalid quantities for negative testing.

  • propertyInvalidScores
    public static IReadOnlyList<int> InvalidScores { get; }

    Gets a set of invalid scores for negative testing.

  • propertyInvalidTaxRates
    public static IReadOnlyList<decimal> InvalidTaxRates { get; }

    Gets a set of invalid tax rates for negative testing.

  • propertyInvalidTemperatures
    public static IReadOnlyList<double> InvalidTemperatures { get; }

    Gets a set of invalid temperature values (below absolute zero) for negative testing.

  • propertyInvalidWeights
    public static IReadOnlyList<double> InvalidWeights { get; }

    Gets a set of invalid weight values for negative testing.

  • propertyValidAge
    public static int ValidAge { get; }

    Gets the first valid age — convenient for single-value tests.

  • propertyValidAges
    public static IReadOnlyList<int> ValidAges { get; }

    Gets a set of valid age values for testing.

  • propertyValidDiscounts
    public static IReadOnlyList<decimal> ValidDiscounts { get; }

    Gets a set of valid discount percentages for testing.

  • propertyValidDistances
    public static IReadOnlyList<double> ValidDistances { get; }

    Gets a set of valid distance values in meters for testing.

  • propertyValidHeights
    public static IReadOnlyList<double> ValidHeights { get; }

    Gets a set of valid height values in cm for testing.

  • propertyValidLatitudes
    public static IReadOnlyList<double> ValidLatitudes { get; }

    Gets a set of valid latitude values for testing.

  • propertyValidLongitudes
    public static IReadOnlyList<double> ValidLongitudes { get; }

    Gets a set of valid longitude values for testing.

  • propertyValidMoneyAmount
    public static decimal ValidMoneyAmount { get; }

    Gets the first valid money amount — convenient for single-value tests.

  • propertyValidMoneyAmounts
    public static IReadOnlyList<decimal> ValidMoneyAmounts { get; }

    Gets a set of valid monetary amounts for testing.

  • propertyValidPercentages
    public static IReadOnlyList<decimal> ValidPercentages { get; }

    Gets a set of valid percentages (0-100) for testing.

  • propertyValidPrices
    public static IReadOnlyList<decimal> ValidPrices { get; }

    Gets a set of valid prices for testing.

  • propertyValidQuantities
    public static IReadOnlyList<int> ValidQuantities { get; }

    Gets a set of valid non-negative quantities for testing.

  • propertyValidScores
    public static IReadOnlyList<int> ValidScores { get; }

    Gets a set of valid scores (0-100) for testing.

  • propertyValidTaxRates
    public static IReadOnlyList<decimal> ValidTaxRates { get; }

    Gets a set of valid tax rates for testing.

  • propertyValidTemperatures
    public static IReadOnlyList<double> ValidTemperatures { get; }

    Gets a set of valid temperature values in Celsius for testing.

  • propertyValidWeights
    public static IReadOnlyList<double> ValidWeights { get; }

    Gets a set of valid weight values in kg for testing.

class

DomainPrimitiveFakeFactory.Shortcuts

Ensamblado: EricksonLopez.DomainPrimitives.Testing
public static class Shortcuts

Provides deterministic fake test data for shortcut domain primitives.

Miembros (6)

  • propertyValidCurrencyCodes
    public static IReadOnlyList<string> ValidCurrencyCodes { get; }

    Gets valid ISO currency codes for testing.

  • propertyValidHexColors
    public static IReadOnlyList<string> ValidHexColors { get; }

    Gets valid Hex Colors for testing.

  • propertyValidIBANs
    public static IReadOnlyList<string> ValidIBANs { get; }

    Gets valid IBAN strings for testing.

  • propertyValidISBNs
    public static IReadOnlyList<string> ValidISBNs { get; }

    Gets valid ISBN strings for testing.

  • propertyValidRatings
    public static IReadOnlyList<decimal> ValidRatings { get; }

    Gets valid rating values (0.0 to 5.0) for testing.

  • propertyValidVINs
    public static IReadOnlyList<string> ValidVINs { get; }

    Gets valid VIN strings for testing.

class

DomainPrimitiveFakeFactory.Strings

Ensamblado: EricksonLopez.DomainPrimitives.Testing
public static class Strings

Provides deterministic fake test data for string-based domain primitives.

Miembros (14)

  • propertyInvalidEmails
    public static IReadOnlyList<string> InvalidEmails { get; }

    Gets a set of invalid email addresses for negative testing.

  • propertyInvalidPhones
    public static IReadOnlyList<string> InvalidPhones { get; }

    Gets a set of invalid phone numbers for negative testing.

  • propertyInvalidSlugs
    public static IReadOnlyList<string> InvalidSlugs { get; }

    Gets a set of invalid URL slugs for negative testing.

  • propertyInvalidUrls
    public static IReadOnlyList<string> InvalidUrls { get; }

    Gets a set of invalid URLs for negative testing.

  • propertyValidCountryCode
    public static string ValidCountryCode { get; }

    Gets the first valid country code — convenient for single-value tests.

  • propertyValidCountryCodes
    public static IReadOnlyList<string> ValidCountryCodes { get; }

    Gets a set of valid ISO 3166-1 alpha-2 country codes for testing.

  • propertyValidEmail
    public static string ValidEmail { get; }

    Gets the first valid email — convenient for single-value tests.

  • propertyValidEmails
    public static IReadOnlyList<string> ValidEmails { get; }

    Gets a set of valid RFC 5322 email addresses for testing.

  • propertyValidPhone
    public static string ValidPhone { get; }

    Gets the first valid phone — convenient for single-value tests.

  • propertyValidPhones
    public static IReadOnlyList<string> ValidPhones { get; }

    Gets a set of valid E.164 phone numbers for testing.

  • propertyValidSlug
    public static string ValidSlug { get; }

    Gets the first valid slug — convenient for single-value tests.

  • propertyValidSlugs
    public static IReadOnlyList<string> ValidSlugs { get; }

    Gets a set of valid URL slugs for testing.

  • propertyValidUrl
    public static string ValidUrl { get; }

    Gets the first valid URL — convenient for single-value tests.

  • propertyValidUrls
    public static IReadOnlyList<string> ValidUrls { get; }

    Gets a set of valid URLs for testing.

class

DomainPrimitiveScenarios

Ensamblado: EricksonLopez.DomainPrimitives.Testing
public static class DomainPrimitiveScenarios

Provides pre-defined test scenarios for each category of domain primitive, covering valid inputs, invalid inputs, boundary conditions, and normalization scenarios.

Notas:

Use these scenarios in parameterized tests (e.g., xUnit `[MemberData]` or `[InlineData]`) to ensure comprehensive coverage without duplicating test data.

Miembros (14)

  • propertyCountryCodeNormalizationScenarios
    public static IEnumerable<object[]> CountryCodeNormalizationScenarios { get; }

    Gets pairs of (rawInput, expectedNormalized) for country code normalization. Demonstrates that `[Trim]` and `[UpperCase]` are applied.

  • propertyEmailNormalizationScenarios
    public static IEnumerable<object[]> EmailNormalizationScenarios { get; }

    Gets pairs of (rawInput, expectedNormalized) for email address normalization. Demonstrates that `[Trim]` and `[LowerCase]` are applied before validation.

  • propertyInvalidAgeValues
    public static IEnumerable<object[]> InvalidAgeValues { get; }

    Gets invalid age values (outside 0–150).

  • propertyInvalidEmailInputs
    public static IEnumerable<object[]> InvalidEmailInputs { get; }

    Gets invalid email inputs that should fail `[Email]` validation.

  • propertyInvalidGuidStrings
    public static IEnumerable<object[]> InvalidGuidStrings { get; }

    Gets invalid GUID strings for `[StrongId<Guid>]` negative testing.

  • propertyInvalidPercentageValues
    public static IEnumerable<object[]> InvalidPercentageValues { get; }

    Gets invalid percentage values (outside 0–100).

  • propertyInvalidPhoneInputs
    public static IEnumerable<object[]> InvalidPhoneInputs { get; }

    Gets invalid phone number inputs.

  • propertyInvalidSlugInputs
    public static IEnumerable<object[]> InvalidSlugInputs { get; }

    Gets invalid URL slug inputs.

  • propertyValidAgeValues
    public static IEnumerable<object[]> ValidAgeValues { get; }

    Gets valid age values (0–150).

  • propertyValidEmailInputs
    public static IEnumerable<object[]> ValidEmailInputs { get; }

    Gets valid email inputs that should pass `[Email]` validation.

  • propertyValidGuidStrings
    public static IEnumerable<object[]> ValidGuidStrings { get; }

    Gets valid GUID strings for `[StrongId<Guid>]` parsing.

  • propertyValidPercentageValues
    public static IEnumerable<object[]> ValidPercentageValues { get; }

    Gets valid percentage values (0–100).

  • propertyValidPhoneInputs
    public static IEnumerable<object[]> ValidPhoneInputs { get; }

    Gets valid E.164 phone number inputs.

  • propertyValidSlugInputs
    public static IEnumerable<object[]> ValidSlugInputs { get; }

    Gets valid URL slug inputs.

class

DomainPrimitiveTestBuilder

Ensamblado: EricksonLopez.DomainPrimitives.Testing
public static class DomainPrimitiveTestBuilder

Provides utilities for creating domain primitive instances in test scenarios, providing both the validated (via `Create()`) and exceptional unvalidated paths.

Notas:

The primary way to create test primitives is through the standard `Create()` factory. Use `CreateUnvalidated<TPrimitive, TValue>` only when you need to test how your system behaves when it receives an already-constructed but logically invalid primitive (e.g., to test repositories or mappers with pre-existing database data).

Miembros (3)

  • methodAssertCreationFails<TPrimitive, TValue>
    public static DomainPrimitiveValidationException AssertCreationFails<TPrimitive, TValue>(TValue value) where TPrimitive : struct, IDomainPrimitive<TPrimitive, TValue> where TValue : notnull

    Validates that creating a primitive from the given value fails and returns the thrown `DomainPrimitiveValidationException` for further inspection.

    value: TValue
    A value expected to fail validation.

    Retorna: The exception thrown during validation.

    Type parameters: TPrimitive: The domain primitive type.; TValue: The backing value type. Exceptions: InvalidOperationException: Thrown if creation succeeds unexpectedly (i.e., the value is actually valid)

  • methodCreate<TPrimitive, TValue>
    public static TPrimitive Create<TPrimitive, TValue>(TValue value) where TPrimitive : struct, IDomainPrimitive<TPrimitive, TValue> where TValue : notnull

    Creates a valid domain primitive using the standard `Create()` factory. Throws `DomainPrimitiveValidationException` if the value fails validation.

    value: TValue
    A valid backing value.

    Retorna: A validated domain primitive instance.

    Type parameters: TPrimitive: The domain primitive type.; TValue: The backing value type. Exceptions: DomainPrimitiveValidationException: Thrown when the value is invalid

  • methodCreateUnvalidated<TPrimitive, TValue>
    public static TPrimitive CreateUnvalidated<TPrimitive, TValue>(TValue value) where TPrimitive : struct, IDomainPrimitive<TPrimitive, TValue> where TValue : notnull

    Creates a domain primitive instance directly from its backing value, bypassing all validation.

    value: TValue
    The raw value to wrap without validation.

    Retorna: An unvalidated domain primitive instance.

    Use with extreme caution and only in testing. This method uses reflection to invoke the private source-generated constructor, which circumvents the domain invariants. Appropriate use cases: - Testing repository/mapper behavior with pre-existing "dirty" database data. - Testing how your application handles primitives reconstructed from external systems. Do not use this to avoid writing proper test data — prefer `DomainPrimitiveFakeFactory` for valid values and `DomainPrimitiveScenarios` for parameterized invalid values. Type parameters: TPrimitive: The domain primitive type.; TValue: The backing value type. Exceptions: InvalidOperationException: Thrown if the generated private constructor cannot be located

class

DomainPrimitiveVerifyExtensions

Ensamblado: EricksonLopez.DomainPrimitives.Testing
public static class DomainPrimitiveVerifyExtensions

Provides extension methods and initializers for Verify snapshot testing with domain primitives.

Miembros (1)

  • methodInitialize
    public static void Initialize()

    Configures Verify to serialize domain primitives using their underlying value rather than as a complex object with a `Value` property.

    This method is idempotent — calling it more than once has no effect. Invoke it once during test module initialization (e.g., in a `static` constructor, a `[ModuleInitializer]`, or a test fixture's `InitializeAsync` method) before any snapshot is generated.

EricksonLopez.DomainPrimitives.Validation#

3
class

CustomValidatorAttribute<TValidator>

Ensamblado: EricksonLopez.DomainPrimitives.Abstractions
public sealed class CustomValidatorAttribute<TValidator> : Attribute
Hereda de: Attribute

Applies a custom `ICustomValidator<T>` to a domain primitive.

Notas:

The validator is invoked after built-in validation (normalization → built-in rules → custom). Multiple `[CustomValidator]` attributes can be stacked. Type parameters: TValidator: The validator type implementing `ICustomValidator<T>`. Must have a parameterless constructor or use only static methods. Example:

[StringPrimitive]
[CustomValidator<LuhnCheckValidator>]
public readonly partial record struct CreditCardNumber;

Miembros (0)

Este tipo declara 0 miembros públicos (por ejemplo, interfaz marcadora o enum/record vacío).

interface

ICustomValidator<T>

Ensamblado: EricksonLopez.DomainPrimitives.Abstractions
public interface ICustomValidator<T>

Defines a reusable custom validator for domain primitive values.

Notas:

Implement this interface to create reusable validation logic that can be applied to multiple domain primitives via `CustomValidatorAttribute<T>`. For one-off validation, use the `static partial void ValidateCustom` hook method directly on the domain primitive type instead. Type parameters: T: The type of value being validated. Example:

public sealed class LuhnCheckValidator : ICustomValidator<string>
{
    public static PrimitiveError Validate(string value)
    {
        var error = PrimitiveError.None;
        if (!LuhnCheck(value))
            error = new PrimitiveError("Luhn.InvalidCheckDigit", "Value has an invalid check digit.");
        return error;
    }
}

Miembros (1)

  • methodValidate
    static abstract PrimitiveError Validate(T value)

    Validates the specified value and returns any validation errors.

    value: T
    The value to validate (already normalized).

    Retorna: The validation errors produced during validation, or an empty collection if validation passes.

record

PrimitiveError

Ensamblado: EricksonLopez.DomainPrimitives.Abstractions
public readonly record struct PrimitiveError

Represents a single validation error from domain primitive validation. A `PrimitiveError` is a zero-allocation value type — no heap allocation occurs on either the error path or the success path (`None`).

Miembros (7)

  • constructorPrimitiveError
    public PrimitiveError(string? Code, string? Message)

    Initializes a new instance of `PrimitiveError`.

    Code: string?
    The error code. If null or whitespace when message is provided, defaults to "VALIDATION_ERROR".
    Message: string?
    The error message. If null when code is provided, defaults to empty string.
  • methodCreate
    public static PrimitiveError Create(string code, string message)

    Creates a new `PrimitiveError` with the given code and message.

    code: string
    The error code (e.g., "LENGTH", "FORMAT"). Must not be null.
    message: string
    The human-readable error message. Must not be null.

    Retorna: A new error instance.

    Exceptions: ArgumentNullException: `code` or `message` is `null`

  • methodDeconstruct
    public void Deconstruct(out string? Code, out string? Message)

    Deconstructs the error into its constituent code and message.

    Code: out string?
    When this method returns, contains the error code.
    Message: out string?
    When this method returns, contains the error message.
  • propertyCode
    public string? Code { get; init; }

    Gets the error code identifying the failure category.

  • propertyIsError
    public bool IsError { get; }

    Gets a value indicating whether this instance represents a validation error. Returns `false` for `None`.

  • propertyMessage
    public string? Message { get; init; }

    Gets the human-readable error message describing the failure.

  • propertyNone
    public static PrimitiveError None { get; }

    Represents no error (a successful validation result).

Buscar en el Ecosistema EricksonLopez.*

Escribe el nombre de una librería, ID de paquete NuGet, tipo .NET o concepto arquitectónico para buscar en el portal.