Skip to content
New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

minLength and maxLength on textarea field causes payload config validation to fail on startup. #11

Closed
richardvanbergen opened this issue Jan 17, 2021 · 4 comments
Assignees

Comments

@richardvanbergen
Copy link

richardvanbergen commented Jan 17, 2021

I hope it's OK to just open issues like this but I think this is a bug so you should hopefully find it useful. 馃槉


Update (Original below)

Problem is actually down to minLength and maxLength properties on textarea. They don't appear to be expected by whatever code is checking the payload config on startup.

Reproduction steps

  1. New project created with yarn create payload-app
  2. Create textarea with minLength or maxLength properties.
  3. Make sure server isn't running.
  4. Start the server and see error.

Expected Behavior

Adding the following config (mostly copied from the documentation) should show a collection with a 'title' and 'description' field.

const Page: CollectionConfig = {
  slug: 'page',
  labels: {
    singular: 'Page',
    plural: 'Pages',
  },
  access: {
    create: () => true,
    read: () => true,
    update: () => true,
    delete: () => true,
  },
  fields: [
    {
      name: 'meta', // required
      type: 'group', // required
      label: 'Page Meta',
      fields: [ // required
        {
          name: 'title',
          type: 'text',
          required: true,
          minLength: 20,
          maxLength: 100,
        },
        {
          name: 'description',
          type: 'textarea',
          required: true,
          minLength: 40,
          maxLength: 160,
        }
      ],
    }
  ]
}

Current Behavior

Payload fails to start at payload configuration step due to schema validation failing.

image

BUT! (and this is why I think it's a bug)

If you comment out the fields, start the server and then uncomment again then it displays as expected.

image

Reproduction steps

  1. New project created with yarn create payload-app
  2. Add pages schema as described above.
  3. Make sure server isn't running.
  4. Start the server and see error.
@richardvanbergen richardvanbergen changed the title Using 'group' type as described in documentation causes payload config validation to fail on startup. minLength and maxLength on textarea field causes payload config validation to fail on startup. Jan 17, 2021
@denolfe denolfe self-assigned this Jan 17, 2021
@denolfe
Copy link
Member

denolfe commented Jan 17, 2021

Hey @richardvanbergen, we appreciate the bug report! It looks like minLength and maxLength fields are missing as allowed values for textarea. I'll get this fixed 馃憤

@richardvanbergen
Copy link
Author

I was going to open a pull request but you got there first. Well done on the quick response! 馃槈

@denolfe
Copy link
Member

denolfe commented Jan 17, 2021

Fixed with 2c98087

@denolfe denolfe closed this as completed Jan 17, 2021
@denolfe
Copy link
Member

denolfe commented Jan 17, 2021

Fix pushed in version 0.1.145 and updated create-payload-app's payload version as well.

@richardvanbergen You can either update your package.json version or any new app w/ create-payload-app will have that version 馃憤

@denolfe denolfe added the bug label Jan 17, 2021
jacobsfletch added a commit to jacobsfletch/payload that referenced this issue Oct 15, 2023
jacobsfletch added a commit to jacobsfletch/payload that referenced this issue Oct 15, 2023
jacobsfletch added a commit to jacobsfletch/payload that referenced this issue Oct 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants