diff --git a/src/GraphQL.FluentValidation/ValidationMiddleware.cs b/src/GraphQL.FluentValidation/ValidationMiddleware.cs index 871a027d..41d70c60 100644 --- a/src/GraphQL.FluentValidation/ValidationMiddleware.cs +++ b/src/GraphQL.FluentValidation/ValidationMiddleware.cs @@ -26,7 +26,8 @@ static ExecutionError ToExecutionError(ValidationFailure failure) { return new($"{failure.PropertyName}: {failure.ErrorMessage}") { - Path = new List {failure.PropertyName} + Path = new List {failure.PropertyName}, + Code = failure.ErrorCode }; } } \ No newline at end of file diff --git a/src/Tests/IntegrationTests.AsyncComplexInvalid.verified.txt b/src/Tests/IntegrationTests.AsyncComplexInvalid.verified.txt index c1901725..0446fcd9 100644 --- a/src/Tests/IntegrationTests.AsyncComplexInvalid.verified.txt +++ b/src/Tests/IntegrationTests.AsyncComplexInvalid.verified.txt @@ -4,13 +4,25 @@ "message": "Inner: Inner async test failed msg.", "path": [ "Inner" - ] + ], + "extensions": { + "code": "AsyncPredicateValidator", + "codes": [ + "AsyncPredicateValidator" + ] + } }, { "message": "Inner.Content: 'Content' must not be empty.", "path": [ "Inner.Content" - ] + ], + "extensions": { + "code": "NotEmptyValidator", + "codes": [ + "NotEmptyValidator" + ] + } } ], "data": { diff --git a/src/Tests/IntegrationTests.AsyncInvalid.verified.txt b/src/Tests/IntegrationTests.AsyncInvalid.verified.txt index ee0caad3..c8f29a25 100644 --- a/src/Tests/IntegrationTests.AsyncInvalid.verified.txt +++ b/src/Tests/IntegrationTests.AsyncInvalid.verified.txt @@ -4,7 +4,13 @@ "message": "Content: The specified condition was not met for 'Content'.", "path": [ "Content" - ] + ], + "extensions": { + "code": "AsyncPredicateValidator", + "codes": [ + "AsyncPredicateValidator" + ] + } } ], "data": { diff --git a/src/Tests/IntegrationTests.ComplexInvalid.verified.txt b/src/Tests/IntegrationTests.ComplexInvalid.verified.txt index 905291a1..9969ca3f 100644 --- a/src/Tests/IntegrationTests.ComplexInvalid.verified.txt +++ b/src/Tests/IntegrationTests.ComplexInvalid.verified.txt @@ -4,13 +4,25 @@ "message": "Inner.Content: 'Content' must not be empty.", "path": [ "Inner.Content" - ] + ], + "extensions": { + "code": "NotEmptyValidator", + "codes": [ + "NotEmptyValidator" + ] + } }, { "message": "Items: 'Items' must not be empty.", "path": [ "Items" - ] + ], + "extensions": { + "code": "NotEmptyValidator", + "codes": [ + "NotEmptyValidator" + ] + } } ], "data": { diff --git a/src/Tests/IntegrationTests.ComplexInvalid2.verified.txt b/src/Tests/IntegrationTests.ComplexInvalid2.verified.txt index 96510fe4..ec4ebb05 100644 --- a/src/Tests/IntegrationTests.ComplexInvalid2.verified.txt +++ b/src/Tests/IntegrationTests.ComplexInvalid2.verified.txt @@ -4,13 +4,25 @@ "message": "Inner: 'Inner' must not be empty.", "path": [ "Inner" - ] + ], + "extensions": { + "code": "NotEmptyValidator", + "codes": [ + "NotEmptyValidator" + ] + } }, { "message": "Items: 'Items' must not be empty.", "path": [ "Items" - ] + ], + "extensions": { + "code": "NotEmptyValidator", + "codes": [ + "NotEmptyValidator" + ] + } } ], "data": { diff --git a/src/Tests/IntegrationTests.DerivedComplexInvalid.verified.txt b/src/Tests/IntegrationTests.DerivedComplexInvalid.verified.txt index c19b17a2..b103127b 100644 --- a/src/Tests/IntegrationTests.DerivedComplexInvalid.verified.txt +++ b/src/Tests/IntegrationTests.DerivedComplexInvalid.verified.txt @@ -4,13 +4,25 @@ "message": "Inner.Content: 'Content' must not be empty.", "path": [ "Inner.Content" - ] + ], + "extensions": { + "code": "NotEmptyValidator", + "codes": [ + "NotEmptyValidator" + ] + } }, { "message": "Items: 'Items' must not be empty.", "path": [ "Items" - ] + ], + "extensions": { + "code": "NotEmptyValidator", + "codes": [ + "NotEmptyValidator" + ] + } } ], "data": { diff --git a/src/Tests/IntegrationTests.Invalid.verified.txt b/src/Tests/IntegrationTests.Invalid.verified.txt index bef250cb..e40f8bcd 100644 --- a/src/Tests/IntegrationTests.Invalid.verified.txt +++ b/src/Tests/IntegrationTests.Invalid.verified.txt @@ -4,7 +4,13 @@ "message": "Content: 'Content' must not be empty.", "path": [ "Content" - ] + ], + "extensions": { + "code": "NotEmptyValidator", + "codes": [ + "NotEmptyValidator" + ] + } } ], "data": {