Skip to content

Commit

Permalink
fix: browser validation error when visiting account page (#10717)
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
AlessioGr authored Jan 22, 2025
1 parent d8682f2 commit c1b912d
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions packages/payload/src/fields/validations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,15 +166,17 @@ export const email: EmailFieldValidation = (
{
collectionSlug,
req: {
payload: { collections },
payload: { collections, config },
t,
},
required,
siblingData,
},
) => {
if (collectionSlug) {
const collection = collections?.[collectionSlug]?.config
const collection =
collections?.[collectionSlug]?.config ??
config.collections.find(({ slug }) => slug === collectionSlug) // If this is run on the client, `collections` will be undefined, but `config.collections` will be available

if (
collection.auth.loginWithUsername &&
Expand Down Expand Up @@ -211,7 +213,9 @@ export const username: UsernameFieldValidation = (
let maxLength: number

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

if (
collection.auth.loginWithUsername &&
Expand Down

0 comments on commit c1b912d

Please sign in to comment.