{"record":{"id":"26e13d00eb327856","repo":"medusajs/medusa","slug":"validation-property-is-missing-at-the-j-index","errorCode":null,"errorMessage":"'validation' property is missing at the ${j} index of the 'forms' property in ${file}.","messagePattern":"'validation' property is missing at the (.+?) index of the 'forms' property in (.+?)\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/admin/admin-vite-plugin/src/custom-fields/generate-custom-field-forms.ts","lineNumber":641,"sourceCode":"        (p) =>\n          isObjectProperty(p) && isIdentifier(p.key, { name: \"defaultValue\" })\n      ) as ObjectProperty | undefined\n\n      if (!defaultValueProperty) {\n        logger.warn(\n          `'defaultValue' property is missing at the ${j} index of the 'forms' property in ${file}.`,\n          { file }\n        )\n        return\n      }\n\n      const validationProperty = fieldObject.properties.find(\n        (p) =>\n          isObjectProperty(p) && isIdentifier(p.key, { name: \"validation\" })\n      ) as ObjectProperty | undefined\n\n      if (!validationProperty) {\n        logger.warn(\n          `'validation' property is missing at the ${j} index of the 'forms' property in ${file}.`,\n          { file }\n        )\n        return\n      }\n\n      const defaultValue = getFormFieldValue(index, j, name, \"defaultValue\")\n      const validation = getFormFieldValue(index, j, name, \"validation\")\n\n      fields.push({\n        name,\n        defaultValue,\n        validation,\n      })\n    })\n\n    configs.push({\n      zone: zone,","sourceCodeStart":623,"sourceCodeEnd":659,"githubUrl":"https://github.com/medusajs/medusa/blob/5e06e544a296b9033f20f71f11c559f81a0e5739/packages/admin/admin-vite-plugin/src/custom-fields/generate-custom-field-forms.ts#L623-L659","documentation":"Field configs must declare a 'validation' property (a function validating input). If a field object has defaultValue but no validation, the plugin warns with the entry index and file and skips the entry, because it cannot generate a complete config.","triggerScenarios":"fields: { myField: { defaultValue: '' } } with no validation key.","commonSituations":"Assuming validation is optional, or writing a field config from a form.define example that omitted it.","solutions":["Add a validation function: validation: (value) => true or a real rule","Ensure both defaultValue and validation exist on every field","Return a string/message from validation to surface errors, or true on success"],"exampleFix":"// before\nfields: { myField: { defaultValue: '' } }\n// after\nfields: { myField: { defaultValue: '', validation: (v) => v.length < 100 } }","handlingStrategy":"validation","validationCode":"Object.entries(f.fields).forEach(([name, def]) => {\n  if (typeof def !== 'object' || !('validation' in def)) {\n    throw new Error(`field '${name}' is missing validation`)\n  }\n})","typeGuard":"const hasValidation = (d: unknown): d is { validation: (v: unknown) => true | string } =>\n  typeof d === 'object' && d !== null && 'validation' in (d as object)","tryCatchPattern":null,"preventionTips":["Require validation explicitly, even if it is a trivial (v) => true","Use a shared FieldConfig type so missing keys fail typecheck"],"tags":["admin","custom-fields","validation","config-validation"],"backgroundTag":"admin-custom-field-form-validation","analyzedSha":"5e06e544a296b9033f20f71f11c559f81a0e5739","analyzedAt":"2026-08-27T07:24:39.599Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}