Skip to content

Commit c1b912d

Browse files
authored
fix: browser validation error when visiting account page (#10717)
Fixes error when visiting account page: ![CleanShot 2025-01-21 at 23 58 48@2x](https://github.com/user-attachments/assets/01502702-319f-46fd-9197-b345eab7fc86)
1 parent d8682f2 commit c1b912d

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

packages/payload/src/fields/validations.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,15 +166,17 @@ export const email: EmailFieldValidation = (
166166
{
167167
collectionSlug,
168168
req: {
169-
payload: { collections },
169+
payload: { collections, config },
170170
t,
171171
},
172172
required,
173173
siblingData,
174174
},
175175
) => {
176176
if (collectionSlug) {
177-
const collection = collections?.[collectionSlug]?.config
177+
const collection =
178+
collections?.[collectionSlug]?.config ??
179+
config.collections.find(({ slug }) => slug === collectionSlug) // If this is run on the client, `collections` will be undefined, but `config.collections` will be available
178180

179181
if (
180182
collection.auth.loginWithUsername &&
@@ -211,7 +213,9 @@ export const username: UsernameFieldValidation = (
211213
let maxLength: number
212214

213215
if (collectionSlug) {
214-
const collection = collections?.[collectionSlug]?.config
216+
const collection =
217+
collections?.[collectionSlug]?.config ??
218+
config.collections.find(({ slug }) => slug === collectionSlug) // If this is run on the client, `collections` will be undefined, but `config.collections` will be available
215219

216220
if (
217221
collection.auth.loginWithUsername &&

0 commit comments

Comments
 (0)