Skip to main content
Version: 0.3.x (0.3.0)

Class ValueObjectValidationResult

Namespace: AdCodicem.ValueObjects.Annotations
Assembly: AdCodicem.ValueObjects.Abstractions.dll

The result DataAnnotations reports a refusal of or with, carrying the code of the rule and the value object type beside the message.

public sealed class ValueObjectValidationResult : ValidationResult

Inheritance​

object ← ValidationResult ← ValueObjectValidationResult

Inherited Members​

ValidationResult.Success, ValidationResult.ToString(), ValidationResult.ErrorMessage, ValidationResult.MemberNames, object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.ReferenceEquals(object?, object?), object.ToString()

Remarks​

A host that hands the result back keeps the code: Validator.TryValidateObject, TryValidateProperty and TryValidateValue list it as it is, and so does CommunityToolkit.Mvvm's ObservableValidator.GetErrors. A host that keeps the message alone loses it: MVC's model state, the errors of AddValidation(), the failures of options validation. The message never carries the code, nor the value refused.

It is the of DataAnnotations, not the a value object's rules return, which is a struct and allocates nothing.

Constructors​

ValueObjectValidationResult(string, IEnumerable<string>?, Type, string)​

Creates the result of a refusal.

public ValueObjectValidationResult(string errorMessage, IEnumerable<string>? memberNames, Type valueObjectType, string errorCode)

Parameters​

errorMessage string

The message, as the host shows it.

memberNames IEnumerable<string>?

The members the refusal is reported under, or null for none.

valueObjectType Type

The value object whose rule refused the value.

errorCode string

The code of the rule, one of or an application's own.

Exceptions​

ArgumentNullException

valueObjectType or errorCode is null.

ArgumentException

errorCode is empty.

Properties​

ErrorCode​

Gets the code of the rule that refused the value, one of or an application's own.

public string ErrorCode { get; }

Property Value​

string

ValueObjectType​

Gets the value object whose rule refused the value.

public Type ValueObjectType { get; }

Property Value​

Type