Utility class for validating object graphs and reporting error and warning messages.
sealed class
|
Validator
|
extends
|
EnumerableBase<IValidateMessage>
|
||
implements
|
IVersioned
|
Have there been any errors during validation so far?
public
property
|
HasErrors
{
get
}
|
||
type
|
bool
|
||
value
|
true
if
there
is
at
least
one
error,
false
if
not. |
Have there been any messages (errors / warnings) during validation so far?
public
property
|
HasMessages
{
get
}
|
||
type
|
bool
|
||
value
|
true
if
there
is
at
least
one
error
or
warning,
false
if
not. |
Have there been any warnings during validation so far?
public
property
|
HasWarnings
{
get
}
|
||
type
|
bool
|
||
value
|
true
if
there
is
at
least
one
warning,
false
if
not. |
Returns the current validation result.
public
property
|
Result
{
get
}
|
||
type
|
ValidateResult
|
||
value
|
The validation result. |
Returns the current version of object.
public
property
|
Version
{
get
}
|
||
type
|
int32
|
||
value
|
The current version number. | ||
implements
|
IVersioned.Version
|
Remarks:
For each modification, the version is incremented by at least one.
Creates a new instance of Validator.
public
constructor
|
Validator
()
|
Uses the given context object for subsequent validation.
public
method
|
BeginContext
(object context)
|
||
params
|
context
|
The context object. |
See also:
EndA dictionary entry of the current value is about to be validated.
public
method
|
BeginEntry
(string key,
ICodeRange culprit = null)
|
||
params
|
key
|
[not-empty]
|
The entry key. |
culprit
|
The
object
to
report
as
the
culprit
if
subsequent
validation
fails.
Defaults
to
null .
|
See also:
EndAn array element of the current value is about to be validated.
public
method
|
BeginIndex
(int32 index,
ICodeRange culprit = null)
|
||
params
|
index
|
[>=0]
|
The array index. |
culprit
|
The
object
to
report
as
the
culprit
if
subsequent
validation
fails.
Defaults
to
null .
|
See also:
EndA named member of the current value is about to be validated.
public
method
|
BeginMember
(string name,
ICodeRange culprit = null)
|
||
params
|
name
|
[not-empty]
|
The member name. |
culprit
|
The
object
to
report
as
the
culprit
if
subsequent
validation
fails.
Defaults
to
null .
|
See also:
EndValidation of the most recent element has finished.
public
method
|
End
()
|
See also:
BeginContext
public
override
method
|
GetEnumerator
()
|
||
type
|
IEnumerator<IValidateMessage>
|
||
implements
|
EnumerableBase.GetEnumerator
|
Emits a validation message.
public
method
|
Message
(IValidateMessage message)
|
||
params
|
message
|
[not-null]
|
The message. |
Emits a validation message for a dictionary entry.
public
method
|
MessageEntry
(string key,
IValidateMessage message,
ICodeRange culprit = null)
|
||
params
|
key
|
[not-empty]
|
The entry key. |
message
|
[not-null]
|
The message. | |
culprit
|
The
object
to
report
as
the
culprit
for
the
message.
Defaults
to
null .
|
See also:
BeginEntryEmits a validation message for an array element.
public
method
|
MessageIndex
(int32 index,
IValidateMessage message,
ICodeRange culprit = null)
|
||
params
|
index
|
[>=0]
|
The element index. |
message
|
[not-null]
|
The message | |
culprit
|
The
object
to
report
as
the
culprit
for
the
message.
Defaults
to
null .
|
See also:
BeginIndexEmits a validation message for a named member.
public
method
|
MessageMember
(string name,
IValidateMessage message,
ICodeRange culprit = null)
|
||
params
|
name
|
[not-empty]
|
The member name. |
message
|
[not-null]
|
The message | |
culprit
|
The
object
to
report
as
the
culprit
for
the
message.
Defaults
to
null .
|
Emits validation messages.
public
method
|
Messages
(ValidateResult result)
|
||
params
|
result
|
The validation result. |
Emits validation messages.
public
method
|
Messages
(IEnumerable<IValidateMessage> messages)
|
||
params
|
messages
|
The
messages
or
null . |