Skip to content
v2.274.0

ValidationResult Class ​

Representation of validation results.

Models a tree of validation errors so that we have as much information as possible about the failure that occurred.

Example ​

ts
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import * as cdk from 'aws-cdk-lib';

declare const validationResults: cdk.ValidationResults;
const validationResult = new cdk.ValidationResult(/* all optional props */ 'errorMessage', /* all optional props */ validationResults);
python
# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
import aws_cdk as cdk

# validation_results: cdk.ValidationResults

validation_result = cdk.ValidationResult("errorMessage", validation_results)
java
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import software.amazon.awscdk.*;

ValidationResults validationResults;

ValidationResult validationResult = new ValidationResult("errorMessage", validationResults);
csharp
// Install: dotnet add package Amazon.CDK.Lib
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
using Amazon.CDK;

ValidationResults validationResults;

var validationResult = new ValidationResult("errorMessage", validationResults);
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import cdk "github.com/aws/aws-cdk-go/awscdk"

var validationResults ValidationResults

validationResult := cdk.NewValidationResult(jsii.String("errorMessage"), validationResults)

Initializer ​

ts
new ValidationResult(errorMessage?: string, results?: ValidationResults)
python
ValidationResult(error_message: typing.Optional[str] = None, results: typing.Optional[ValidationResults] = None)
java
new ValidationResult(String errorMessage, ValidationResults results)
csharp
new ValidationResult(string? errorMessage = null, ValidationResults? results = null)
go
NewValidationResult(ErrorMessage *string, Results ValidationResults)

Properties ​

errorMessagestringerror_messagestrerrorMessageStringErrorMessagestringErrorMessage*stringrequired#
isSuccessbooleanis_successboolisSuccessBooleanIsSuccessboolIsSuccess*boolrequired#

Methods ​

assertSuccess(): voiddef assert_success(self, ) -> Nonepublic void assertSuccess()public void AssertSuccess()func AssertSuccess()#
Turn a failed validation into an exception.
errorTree(): stringdef error_tree(self, ) -> strpublic String errorTree()public string ErrorTree()func ErrorTree() *string#
Return a string rendering of the tree of validation failures.
prefix(message: string): ValidationResult // chainabledef prefix(self, message: str) -> ValidationResultpublic ValidationResult prefix(String message)public ValidationResult Prefix(string message)func Prefix(Message *string) ValidationResult#
Wrap this result with an error message, if it concerns an error.