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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quick Start Docs, curl example different, when Postgres is used. #231

Closed
abossard opened this issue Feb 22, 2016 · 6 comments
Closed

Quick Start Docs, curl example different, when Postgres is used. #231

abossard opened this issue Feb 22, 2016 · 6 comments

Comments

@abossard
Copy link

I refer to: http://docs.feathersjs.com/getting-started/quick-start.html Step 7.

Current curl example:

curl 'http://localhost:3030/messages/' -H 'Content-Type: application/json' --data-binary '{ "text": "Hello Feathers!" }'

Fails with Postgres with this error:

info: BadRequest: Validation error: `text` must only contain alpha numeric characters
    at Object.construct (/Users/andre/Desktop/projects/feathers-chat/node_modules/core-js/modules/es6.reflect.construct.js:22:24)
    at BadRequest.ExtendableBuiltin (/Users/andre/Desktop/projects/feathers-chat/node_modules/feathers-errors/lib/index.js:27:28)
    at BadRequest.FeathersError (/Users/andre/Desktop/projects/feathers-chat/node_modules/feathers-errors/lib/index.js:105:87)
    at new BadRequest (/Users/andre/Desktop/projects/feathers-chat/node_modules/feathers-errors/lib/index.js:145:79)
    at errorHandler (/Users/andre/Desktop/projects/feathers-chat/node_modules/feathers-sequelize/lib/utils.js:28:25)
    at tryCatcher (/Users/andre/Desktop/projects/feathers-chat/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/Users/andre/Desktop/projects/feathers-chat/node_modules/bluebird/js/release/promise.js:497:31)
    at Promise._settlePromise (/Users/andre/Desktop/projects/feathers-chat/node_modules/bluebird/js/release/promise.js:555:18)
    at Promise._settlePromise0 (/Users/andre/Desktop/projects/feathers-chat/node_modules/bluebird/js/release/promise.js:600:10)
    at Promise._settlePromises (/Users/andre/Desktop/projects/feathers-chat/node_modules/bluebird/js/release/promise.js:679:18)
    at Promise._reject (/Users/andre/Desktop/projects/feathers-chat/node_modules/bluebird/js/release/promise.js:643:18)
    at Promise._settlePromise (/Users/andre/Desktop/projects/feathers-chat/node_modules/bluebird/js/release/promise.js:570:21)
    at Promise._settlePromise0 (/Users/andre/Desktop/projects/feathers-chat/node_modules/bluebird/js/release/promise.js:600:10)
    at Promise._settlePromises (/Users/andre/Desktop/projects/feathers-chat/node_modules/bluebird/js/release/promise.js:679:18)
    at Promise._reject (/Users/andre/Desktop/projects/feathers-chat/node_modules/bluebird/js/release/promise.js:643:18)
    at Promise._settlePromise (/Users/andre/Desktop/projects/feathers-chat/node_modules/bluebird/js/release/promise.js:570:21)
error: (400) Route: /messages/ - Validation error: `text` must only contain alpha numeric characters

If I just use a single word (no space and no exclamation mark) it works:
curl 'http://localhost:3030/messages' -H 'Content-Type: application/json' --data-binary '{ "text": "Hello3"}'

I suggest to change the example or to use different template parameters in the sequelize model.

@kulakowka
Copy link

If you create application with generator-featers,
You should change validation option from isAlphaNumeric to isAlphanumeric in your models: /src/services/user/user-model.js. There were mistake in generator. Now it's fixed. You should update generator from npm, too.

Before:

let user = sequelize.define('user', {
    text: {
      type: Sequelize.STRING,
      allowNull: false,
      unique: true,
      validate: {
        isAlphaNumeric: { msg: '`text` must only contain alpha numeric characters' }
      }
    }
  }, {
    freezeTableName: true
  });

After:

let user = sequelize.define('user', {
    text: {
      type: Sequelize.STRING,
      allowNull: false,
      unique: true,
      validate: {
        isAlphanumeric: { msg: '`text` must only contain alpha numeric characters' }
      }
    }
  }, {
    freezeTableName: true
  });

@kulakowka
Copy link

We fixed this typo in generator feathersjs-ecosystem/generator-feathers#39

@abossard
Copy link
Author

Thank you very much! Great!

@daffl
Copy link
Member

daffl commented Feb 22, 2016

That validation doesn't really make any sense anyway does it? A message text can be anything. I'm thinking we should remove it.

@ekryski
Copy link
Contributor

ekryski commented Feb 23, 2016

@daffl ya it doesn't really make sense. It was only added to show how you can do validations. Realistically you'd probably be changing your model pretty quick anyway.

@lock
Copy link

lock bot commented Feb 7, 2019

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue with a link to this issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Feb 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants