Class ValidationResultReason
- Namespace
- Cratis.Arc.Validation
- Assembly
- Cratis.Arc.Core.dll
Represents what composed a ValidationResult - the machine-readable counterpart to its message.
public record ValidationResultReason : ConceptAs<string>, IComparable<ConceptAs<string>>, IComparable<string>, IComparable, IEquatable<ConceptAs<string>>, IEquatable<ValidationResultReason>
- Inheritance
-
ValidationResultReason
- Implements
- Inherited Members
- Extension Methods
Remarks
A rejection's message is a developer diagnostic, not end-user copy, and it is the only thing that has ever distinguished one kind of rejection from another. That leaves a client matching English prose to tell an authored business-rule rejection from something the framework composed on its behalf - which breaks silently the moment the wording changes, and cannot tell the framework's sentence from an authored rule that reads the same.
This is deliberately an open set rather than an enum. Rejections are composed in Arc, in Chronicle and in consumer code, and a closed set would make every new kind a breaking change for whoever switches over it.
Constructors
ValidationResultReason(ValidationResultReason)
protected ValidationResultReason(ValidationResultReason original)
Parameters
originalValidationResultReason
ValidationResultReason(string)
Represents what composed a ValidationResult - the machine-readable counterpart to its message.
public ValidationResultReason(string Value)
Parameters
ValuestringThe reason identifier.
Remarks
A rejection's message is a developer diagnostic, not end-user copy, and it is the only thing that has ever distinguished one kind of rejection from another. That leaves a client matching English prose to tell an authored business-rule rejection from something the framework composed on its behalf - which breaks silently the moment the wording changes, and cannot tell the framework's sentence from an authored rule that reads the same.
This is deliberately an open set rather than an enum. Rejections are composed in Arc, in Chronicle and in consumer code, and a closed set would make every new kind a breaking change for whoever switches over it.
Fields
ConcurrencyViolation
The append was rejected because the event source moved on since it was read. The failure is retryable - re-read and resubmit - which is the fact a free-text message cannot convey.
public static readonly ValidationResultReason ConcurrencyViolation
Field Value
ConstraintViolation
A constraint on the event store rejected the append.
public static readonly ValidationResultReason ConstraintViolation
Field Value
DependencyUnavailable
Something the command needed in order to be evaluated was not available - most often the read model a validator depends on, which could not be resolved from the command's key.
public static readonly ValidationResultReason DependencyUnavailable
Field Value
Remarks
This is raised before any rule runs, so no rule rejected anything: the command was never evaluated against them at all. That is a different fact from a rule rejection and wants a different response, and it is the one most easily mistaken for a domain rejection because the message reads like one.
FrameworkFailure
The framework could not fulfill a command contract or complete its effects. No authored rule rejected input.
public static readonly ValidationResultReason FrameworkFailure
Field Value
MalformedRequest
The request itself could not be read - a malformed body, or a value that could not be bound to the member it was sent for. No rule was reached.
public static readonly ValidationResultReason MalformedRequest
Field Value
Rule
A rule authored by the application rejected the input. The default: the message is the author's, and the client should show it.
public static readonly ValidationResultReason Rule
Field Value
ValidatorFailed
A validator threw while validating, and the framework substituted a result for the one the validator would have produced. Nothing about the authored rules survives, so a client that shows the message shows a developer diagnostic in place of an authored reason.
public static readonly ValidationResultReason ValidatorFailed
Field Value
Properties
EqualityContract
protected override Type EqualityContract { get; }
Property Value
Methods
Deconstruct(out string)
public void Deconstruct(out string Value)
Parameters
Valuestring
Equals(ValidationResultReason?)
public virtual bool Equals(ValidationResultReason? other)
Parameters
otherValidationResultReason
Returns
Equals(ConceptAs<string>?)
public override sealed bool Equals(ConceptAs<string>? other)
Parameters
Returns
Equals(object?)
public override bool Equals(object? obj)
Parameters
objobject
Returns
GetHashCode()
public override int GetHashCode()
Returns
PrintMembers(StringBuilder)
protected override bool PrintMembers(StringBuilder builder)
Parameters
builderStringBuilder
Returns
Operators
operator ==(ValidationResultReason?, ValidationResultReason?)
public static bool operator ==(ValidationResultReason? left, ValidationResultReason? right)
Parameters
leftValidationResultReasonrightValidationResultReason
Returns
operator !=(ValidationResultReason?, ValidationResultReason?)
public static bool operator !=(ValidationResultReason? left, ValidationResultReason? right)
Parameters
leftValidationResultReasonrightValidationResultReason