I'm receiving a validation error for a non-existent field on a collection in the admin. My error states The following field is invalid: email
. I don't have an email field on the collection. Updates work without issue / creating other collections seemingly works as well. Any advice on how to best go about debugging this?
const Locations: CollectionConfig = {
slug: "locations",
admin: {
useAsTitle: "locationName",
},
fields: [
{
name: "locationName",
type: "text",
},
{
name: "address",
type: "text",
},
{
name: "address2",
type: "text",
},
{
name: "city",
type: "text",
},
{
name: "state",
type: "text",
},
{
name: "postalCode",
label: "Zip code",
type: "text",
},
],
};
[0] [17:25:36] ERROR (payload): ValidationError: The following field is invalid: email
[0] at new ExtendableError (.../node_modules/payload/src/errors/APIError.ts:26:11)
[0] at new APIError (.../node_modules/payload/src/errors/APIError.ts:43:5)
[0] at new ValidationError (.../node_modules/payload/src/errors/ValidationError.ts:6:5)
[0] at Payload.create (.../node_modules/payload/src/collections/operations/create.ts:209:11)
[0] at processTicksAndRejections (node:internal/process/task_queues:96:5)
[0] at Payload.create (.../node_modules/payload/src/collections/requestHandlers/create.ts:14:17)
Hey @ryanlanciaux I can't see anything wrong in what you've shared. Is it possible you had an email field previously and have not saved changes or restarted the server? Using yarn dev
should pick up on changes as it uses nodemon
, though I have seen instances where file changes are missed for some reason, stop it and restart if you haven't already.
Here are some other thoughts:
api/locations
route and not something else like api/users
?payload.init( {
// [...]
onInit: (app) => {
console.log(app.collections.locations.Model.schema.tree);
payload.logger.info(`Payload Admin URL: ${payload.getAdminURL()}`);
},
});
If the schema does not have it and yet the validation still expects email, I have no answer and will have to do some more digging.
Hey @ryanlanciaux have you have had success with this or not? I would be happy to take a look at anything for your benefit if you are stuck in any way.
LMK, cheers!
I have no problems with email, but the original question is more I feel where to best access more detailed errors during validation. Now I personally write extra checks in decentralised places I have access to, but if something would be wrong with the email setting I wouldn't know where to start...
SO, maybe I'm missing a doc (I see you guys secretly tweaking it), but a clear way to get more than error in collections[3][5]
would be nice
Ahhhh @ryanlanciaux I bet you are having the same exact issue as was discussed here:
@Ontopic — you're actually talking about startup config validation (I think) which is totally something that we need to improve. We are using Joi
and there is definitely a way to make this better. That's on our radar to improve for sure.
Sorry I've been away from this for a bit and thanks so much for following-up. I'll confirm that this is what I'm bumping into and report back. 👍
Okay! #237 adds the collection, global slugs and field names to the config validation errors.
Star
Discord
online
Get help straight from the Payload team with an Enterprise License.