medusajs/medusa · warning

'validation' property is missing at the ${j} index of the 'f

Error message

'validation' property is missing at the ${j} index of the 'forms' property in ${file}.

What it means

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.

Source

Thrown at packages/admin/admin-vite-plugin/src/custom-fields/generate-custom-field-forms.ts:641

        (p) =>
          isObjectProperty(p) && isIdentifier(p.key, { name: "defaultValue" })
      ) as ObjectProperty | undefined

      if (!defaultValueProperty) {
        logger.warn(
          `'defaultValue' property is missing at the ${j} index of the 'forms' property in ${file}.`,
          { file }
        )
        return
      }

      const validationProperty = fieldObject.properties.find(
        (p) =>
          isObjectProperty(p) && isIdentifier(p.key, { name: "validation" })
      ) as ObjectProperty | undefined

      if (!validationProperty) {
        logger.warn(
          `'validation' property is missing at the ${j} index of the 'forms' property in ${file}.`,
          { file }
        )
        return
      }

      const defaultValue = getFormFieldValue(index, j, name, "defaultValue")
      const validation = getFormFieldValue(index, j, name, "validation")

      fields.push({
        name,
        defaultValue,
        validation,
      })
    })

    configs.push({
      zone: zone,

View on GitHub (pinned to 5e06e544a2)

Solutions

  1. Add a validation function: validation: (value) => true or a real rule
  2. Ensure both defaultValue and validation exist on every field
  3. Return a string/message from validation to surface errors, or true on success

Example fix

// before
fields: { myField: { defaultValue: '' } }
// after
fields: { myField: { defaultValue: '', validation: (v) => v.length < 100 } }
Defensive patterns

Strategy: validation

Validate before calling

Object.entries(f.fields).forEach(([name, def]) => {
  if (typeof def !== 'object' || !('validation' in def)) {
    throw new Error(`field '${name}' is missing validation`)
  }
})

Type guard

const hasValidation = (d: unknown): d is { validation: (v: unknown) => true | string } =>
  typeof d === 'object' && d !== null && 'validation' in (d as object)

Prevention

When it happens

Trigger: fields: { myField: { defaultValue: '' } } with no validation key.

Common situations: Assuming validation is optional, or writing a field config from a form.define example that omitted it.

Related errors


AI-assisted analysis of medusajs/medusa@5e06e544a2 (2026-08-27). Data as JSON: /api/errors/26e13d00eb327856. Report an issue: GitHub.