Table of Contents

Class ActorId

Namespace
Trellis.Authorization
Assembly
Trellis.Authorization.dll

Strongly-typed identifier for an authenticated principal (the value behind Id).

[JsonConverter(typeof(ParsableJsonConverter<ActorId>))]
public sealed class ActorId : RequiredString<ActorId>, IComparable<ValueObject>, IComparable, IEquatable<ValueObject>, IConvertible, IFormattable, IScalarValue<ActorId, string>, IParsable<ActorId>
Inheritance
ActorId
Implements
Inherited Members
Extension Methods

Remarks

ActorId wraps the raw claim string (typically the JWT sub or AAD oid) so that authorization-layer APIs can accept and return a domain type instead of an untyped string. Consumers that store the actor's identity at aggregate boundaries (e.g. Order.CreatedByActorId) should reuse this type to keep the principal-identity concept consistent across the framework, audit fields, and any cross-aggregate comparison that asks "did the same actor do both of these things?".

Domain identifiers (a customer ID, a tenant member ID, a domain user aggregate's primary key) are not the same concept as a principal ID. Those remain whatever VO the domain models. Use ActorId for authentication-layer principal identity only — what the auth pipeline produced — and resolve to domain identity at the application service boundary if the two differ.

Uses [Trim, NotDefault] on top of RequiredString<TSelf> so the value is trimmed on construction and an empty or whitespace-only id is rejected. This matches the original Actor constructor's ArgumentException.ThrowIfNullOrWhiteSpace guard; the trim is a deliberate, documented normalization step on top of that.

Methods

Create(string?, string?)

Creates a validated instance from a string. Throws if validation fails.

public static ActorId Create(string? value, string? fieldName = null)

Parameters

value string

The string value to validate.

fieldName string

Optional field name for validation error messages.

Returns

ActorId

The validated value object.

Exceptions

InvalidOperationException

Thrown when validation fails.

Parse(string, IFormatProvider?)

Parses the input into a ActorId or throws TrellisValidationFormatException when the input fails validation.

public static ActorId Parse(string s, IFormatProvider? provider)

Parameters

s string

The value to parse.

provider IFormatProvider

Format provider (currently unused for non-IFormattable bases).

Returns

ActorId

TryCreate(string?, string?)

Creates a validated instance from a string. Required by IScalarValue interface for model binding and JSON deserialization.

public static Result<ActorId> TryCreate(string? value, string? fieldName = null)

Parameters

value string

The string value to validate.

fieldName string

Optional field name for validation error messages.

Returns

Result<ActorId>

Success with the value object, or Failure with validation errors.

TryParse(string?, IFormatProvider?, out ActorId)

Attempts to parse the input into a ActorId. Returns false when the input fails validation.

public static bool TryParse(string? s, IFormatProvider? provider, out ActorId result)

Parameters

s string

The value to parse.

provider IFormatProvider

Format provider (currently unused for non-IFormattable bases).

result ActorId

The parsed value on success; otherwise default.

Returns

bool

Operators

explicit operator ActorId(string)

Explicitly wraps a raw actorId value into a validated ActorId. Equivalent to calling Create.

public static explicit operator ActorId(string actorId)

Parameters

actorId string

Returns

ActorId