Validator

Description

sealed class Tinman.Core.Validating.Validator

Derived from

EnumerableBase<IValidateMessage> abstract
IVersioned

A utility class for validating object graphs and reporting error and warning messages.

The IVersioned.Version property returns the message count ( CountMessages).

Public / Constructors

Validator


public constructor Validator → ()

Creates a new instance of Validator.

Public / Methods

Begin​Context


public method BeginContext → (1)

context in : object

The context object.

Uses the given context object for subsequent validation.

See also

Validator.End

Begin​Entry


public method BeginEntry → (2)

key in : string

[not-empty]
The entry key.

culprit opt : ICodeRange = null

The object to report as the culprit if subsequent validation fails.

A dictionary entry of the current value is about to be validated.

See also

Validator.End

Begin​Index


public method BeginIndex → (2)

index in : int32

[>=0]
The array index.

culprit opt : ICodeRange = null

The object to report as the culprit if subsequent validation fails.

An array element of the current value is about to be validated.

See also

Validator.End

Begin​Member


public method BeginMember → (2)

name in : string

[not-empty]
The member name.

culprit opt : ICodeRange = null

The object to report as the culprit if subsequent validation fails.

A named member of the current value is about to be validated.

See also

Validator.End

End


public method End → ()

Validation of the most recent element has finished.

Message


public method Message → (1)

message in : IValidateMessage

[not-null]
The message.

Emits a validation message.

Message​Entry


public method MessageEntry → (3)

key in : string

[not-empty]
The entry key.

message in : IValidateMessage

[not-null]
The message.

culprit opt : ICodeRange = null

The object to report as the culprit for the message.

Emits a validation message for a dictionary entry.

Message​Index


public method MessageIndex → (3)

index in : int32

[>=0]
The element index.

message in : IValidateMessage

[not-null]
The message

culprit opt : ICodeRange = null

The object to report as the culprit for the message.

Emits a validation message for an array element.

Message​Member


public method MessageMember → (3)

name in : string

[not-empty]
The member name.

message in : IValidateMessage

[not-null]
The message

culprit opt : ICodeRange = null

The object to report as the culprit for the message.

Emits a validation message for a named member.

Messages

2 overloads


public method Messages1 → (1)

result in : ValidateResult

The validation result.

Emits validation messages.


public method Messages2 → (1)

messages in : IEnumerable<IValidateMessage>

The messages or null.

Emits validation messages.

Validate​Entry


public method ValidateEntry → (2)

name in : string

[not-empty]
The entry name.

validatable in : IValidatable

The object to validate. If null, no validation will be performed.

Convenience method that calls IValidatable.Validate on the given validatable in object, passing this as argument and wrapping the call in BeginEntry and End.

Validate​Index


public method ValidateIndex → (2)

index in : int32

[>=0]
The element index.

validatable in : IValidatable

The object to validate. If null, no validation will be performed.

Convenience method that calls IValidatable.Validate on the given validatable in object, passing this as argument and wrapping the call in BeginIndex and End.

Validate​Member


public method ValidateMember → (2)

name in : string

[not-empty]
The member name.

validatable in : IValidatable

The object to validate. If null, no validation will be performed.

Convenience method that calls IValidatable.Validate on the given validatable in object, passing this as argument and wrapping the call in BeginMember and End.

Public / Attributes

Count​Errors


public attribute CountErrors → (get)

value : int32

[>=0]
The number of error messages.

Returns the number of error messages.

The count can be used to detect if a call to IValidatable.Validate has emitted error messages.

Count​Messages


public attribute CountMessages → (get)

value : int32

[>=0]
The number of validation messages.

Returns the number of validation messages.

The count can be used to detect if a call to IValidatable.Validate has emitted some messages.

Count​Warning


public attribute CountWarning → (get)

value : int32

[>=0]
The number of warning messages.

Returns the number of warning messages.

The count can be used to detect if a call to IValidatable.Validate has emitted warning messages.

Has​Errors


public attribute HasErrors → (get)

value : bool

true if there is at least one error, false if not.

Have there been any errors during validation so far?

Has​Messages


public attribute HasMessages → (get)

value : bool

true if there is at least one error or warning, false if not.

Have there been any messages (errors / warnings) during validation so far?

Has​Warnings


public attribute HasWarnings → (get)

value : bool

true if there is at least one warning, false if not.

Have there been any warnings during validation so far?

Result


public attribute Result → (get)

value : ValidateResult

[not-null]
The validation result.

Returns the current validation result.