Skip to content

M_Ifp_Validation_ValidationRule_1_ValidateObject

Martin Strecker edited this page Mar 9, 2019 · 6 revisions

ValidationRule(T).ValidateObject Method

Checks the objectToValidate and returns a ValidationOutcome.

Namespace: Ifp.Validation
Assembly: Ifp.Validation (in Ifp.Validation.dll) Version: 1.4.0

Syntax

C#

public abstract ValidationOutcome ValidateObject(
	T objectToValidate
)

VB

Public MustOverride Function ValidateObject ( 
	objectToValidate As T
) As ValidationOutcome

C++

public:
virtual ValidationOutcome^ ValidateObject(
	T objectToValidate
) abstract

F#

abstract ValidateObject : 
        objectToValidate : 'T -> ValidationOutcome 

Parameters

 

objectToValidate
Type: T
The object to validate.

Return Value

Type: ValidationOutcome
A ValidationOutcome that represents the result of the validation.

Implements

IValidationRule(T).ValidateObject(T)

Remarks

You can use the ToFailure(String, FailureSeverity) extension method to construct a ValidationOutcome.

Examples

Indicate success by returning Success.

C#

public override ValidationOutcome ValidateObject(Animal objectToValidate)
{
    return ValidationOutcome.Success;
}

Return a ValidationOutcome by using the Failure(FailureSeverity, String) method.

C#

public override ValidationOutcome ValidateObject(Animal objectToValidate)
{
    return ValidationOutcome.Failure(FailureSeverity.Error, "This is an error message.");
}

Return a ValidationOutcome using the String extension method ToFailure(String, FailureSeverity).

C#

public override ValidationOutcome ValidateObject(Animal objectToValidate)
{
    return "This is an error message.".ToFailure(FailureSeverity.Error);
}

See Also

Reference

ValidationRule(T) Class
Ifp.Validation Namespace

Clone this wiki locally