Skip to content

Commit 729b676

Browse files
jaycetdeJayce Pulsipher
andauthored
fix(plugin-nested-docs): check error name that is changed at compile time (#12798)
Since `ValidationErrorName` [gets dynamically reassigned during compilation](https://github.com/payloadcms/payload/blob/main/packages/payload/src/errors/ValidationError.ts#L11), we must reference the variable rather than use a static string to compare against Co-authored-by: Jayce Pulsipher <jpulsipher@nav.com>
1 parent 77f3805 commit 729b676

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

packages/plugin-nested-docs/src/hooks/resaveChildren.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import type {
66
ValidationError,
77
} from 'payload'
88

9-
import { APIError } from 'payload'
9+
import { APIError, ValidationErrorName } from 'payload'
1010

1111
import type { NestedDocsPluginConfig } from '../types.js'
1212

@@ -96,7 +96,7 @@ const resave = async ({ collection, doc, draft, pluginConfig, req }: ResaveArgs)
9696
req.payload.logger.error(err)
9797

9898
if (
99-
(err as ValidationError)?.name === 'ValidationError' &&
99+
(err as ValidationError)?.name === ValidationErrorName &&
100100
(err as ValidationError)?.data?.errors?.length
101101
) {
102102
throw new APIError(

0 commit comments

Comments
 (0)