-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Open
Labels
Description
Describe the Bug
Payload bug / inconsistency in how text handles "localized + required" during validation, especially when you’re writing localized objects (or using locale: 'all'). The moment you change the field type from text to textarea or change the required: false, create API calls start working (also stored as a string).
payload.config.ts:
export const locales = ['hi', 'en']
export default buildConfig({
...
localization: {
locales: locales.map((locale) => ({
code: locale,
label: {
hi: 'हिन्दी',
en: 'English',
}[locale]!,
})),
defaultLocale: 'hi',
fallback: true,
},
...
})
Pages.ts
...
fields: [
{
name: 'title',
type: 'text',
localized: true,
required: true,
},
...
Link to the code that reproduces this issue
https://github.com/sharmasourabh/localized-required-text-issue-
Reproduction Steps
To replicate the issue, run the following command:
$ pnpm payload run src/seed.ts
ValidationError: The following field is invalid: Title
....
status: 400,
[cause]: {
id: undefined,
collection: 'pages',
errors: [
{
label: 'Title',
message: 'This field is required.',
path: 'title'
}
],
I have also tried using locale: 'all'. However same issue:
await payload.create({
overrideAccess: true,
collection: COLLECTION_SLUG,
fallbackLocale: false,
locale: 'all',
data: {...}
})
Which area(s) are affected?
Not sure
Environment Info
payload: 3.78.0
Operating System:
Platform: darwin
Arch: x64
Version: Darwin Kernel Version 24.6.0
Available memory (MB): 16384
Available CPU cores: 8
Reactions are currently unavailable