Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix: browser validation error when visiting account page #10717

Merged
merged 1 commit into from
Jan 22, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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