Class ValidationResult
- Namespace
- Cratis.Arc.Validation
- Assembly
- Cratis.Arc.Core.dll
Represents the an failed validation rule.
public record ValidationResult : IEquatable<ValidationResult>
- Inheritance
-
ValidationResult
- Implements
- Inherited Members
- Extension Methods
Remarks
State belongs to whoever authored the rule - it carries FluentValidation's WithState value
straight through - so it is not where the framework says what kind of rejection this is. That is
Reason, and which specific thing within that category is ReasonDetail.
Constructors
ValidationResult(ValidationResult)
protected ValidationResult(ValidationResult original)
Parameters
originalValidationResult
ValidationResult(ValidationResultSeverity, string, IEnumerable<string>, object)
Represents the an failed validation rule.
public ValidationResult(ValidationResultSeverity Severity, string Message, IEnumerable<string> Members, object State)
Parameters
SeverityValidationResultSeverityThe ValidationResultSeverity of the result.
MessagestringMessage of the error.
MembersIEnumerable<string>Collection of camelCase field paths that caused the failure.
StateobjectState associated with the validation result.
Remarks
State belongs to whoever authored the rule - it carries FluentValidation's WithState value
straight through - so it is not where the framework says what kind of rejection this is. That is
Reason, and which specific thing within that category is ReasonDetail.
Properties
EqualityContract
protected virtual Type EqualityContract { get; }
Property Value
Members
Gets the affected members, reported as camelCase field paths.
public IEnumerable<string> Members { get; init; }
Property Value
Message
Message of the error.
public string Message { get; init; }
Property Value
Reason
Gets what composed this result. Defaults to Rule - an authored rule rejected the input - so anything the framework composes on the application's behalf has to say so.
public ValidationResultReason Reason { get; init; }
Property Value
ReasonDetail
Gets the identity of the specific thing that produced this result within its Reason category, or null when the reason carries no finer identity. Reason says a constraint rejected the command; this says which constraint - so a client can branch on identity instead of parsing Message, which is prose written for a human and free to change.
public string? ReasonDetail { get; init; }
Property Value
Remarks
Deliberately a string and deliberately not named after any one reason: this type is Arc's general validation result, it does not depend on Chronicle, and every category is free to fill this in with whatever names its own rejections - a constraint name today, something else tomorrow.
Severity
The ValidationResultSeverity of the result.
public ValidationResultSeverity Severity { get; init; }
Property Value
State
State associated with the validation result.
public object State { get; init; }
Property Value
Methods
Deconstruct(out ValidationResultSeverity, out string, out IEnumerable<string>, out object)
public void Deconstruct(out ValidationResultSeverity Severity, out string Message, out IEnumerable<string> Members, out object State)
Parameters
SeverityValidationResultSeverityMessagestringMembersIEnumerable<string>Stateobject
Equals(ValidationResult?)
public virtual bool Equals(ValidationResult? other)
Parameters
otherValidationResult
Returns
Equals(object?)
public override bool Equals(object? obj)
Parameters
objobject
Returns
Error(string, IEnumerable<string>?, object?, ValidationResultReason?, string?)
Creates a new ValidationResult representing an error.
public static ValidationResult Error(string message, IEnumerable<string>? members = null, object? state = null, ValidationResultReason? reason = null, string? reasonDetail = null)
Parameters
messagestringMessage of the error.
membersIEnumerable<string>Collection of member names that caused the error.
stateobjectState associated with the validation result.
reasonValidationResultReasonWhat composed the result. Defaults to Rule.
reasonDetailstringThe identity of the specific thing within
reasonthat produced the result.
Returns
GetHashCode()
public override int GetHashCode()
Returns
Information(string, IEnumerable<string>?, object?, ValidationResultReason?, string?)
Creates a new ValidationResult representing information.
public static ValidationResult Information(string message, IEnumerable<string>? members = null, object? state = null, ValidationResultReason? reason = null, string? reasonDetail = null)
Parameters
messagestringMessage of the information.
membersIEnumerable<string>Collection of member names that are related to the information.
stateobjectState associated with the validation result.
reasonValidationResultReasonWhat composed the result. Defaults to Rule.
reasonDetailstringThe identity of the specific thing within
reasonthat produced the result.
Returns
PrintMembers(StringBuilder)
protected virtual bool PrintMembers(StringBuilder builder)
Parameters
builderStringBuilder
Returns
ToString()
public override string ToString()
Returns
Warning(string, IEnumerable<string>?, object?, ValidationResultReason?, string?)
Creates a new ValidationResult representing a warning.
public static ValidationResult Warning(string message, IEnumerable<string>? members = null, object? state = null, ValidationResultReason? reason = null, string? reasonDetail = null)
Parameters
messagestringMessage of the warning.
membersIEnumerable<string>Collection of member names that caused the warning.
stateobjectState associated with the validation result.
reasonValidationResultReasonWhat composed the result. Defaults to Rule.
reasonDetailstringThe identity of the specific thing within
reasonthat produced the result.
Returns
Operators
operator ==(ValidationResult?, ValidationResult?)
public static bool operator ==(ValidationResult? left, ValidationResult? right)
Parameters
leftValidationResultrightValidationResult
Returns
operator !=(ValidationResult?, ValidationResult?)
public static bool operator !=(ValidationResult? left, ValidationResult? right)
Parameters
leftValidationResultrightValidationResult