Skip to content

Validators for Data Types #222

Closed
Closed

Description

@ZoeAde

You should not be able to enter data types that do not exist in Sequelize.

node_modules/.bin/sequelize model:create --name Todo --attributes "name:RYANGOSLING"

Results in:

'use strict';
module.exports = {
  up: function(queryInterface, Sequelize) {
    return queryInterface.createTable('Todos', {
      id: {
        allowNull: false,
        autoIncrement: true,
        primaryKey: true,
        type: Sequelize.INTEGER
      },
      name: {
        type: Sequelize.RYANGOSLING
      },
      createdAt: {
        allowNull: false,
        type: Sequelize.DATE
      },
      updatedAt: {
        allowNull: false,
        type: Sequelize.DATE
      }
    });
  },
  down: function(queryInterface, Sequelize) {
    return queryInterface.dropTable('Todos');
  }
};

Activity

  1. mjhea0 commented on Nov 15, 2015

    @mjhea0

    👍

  2. sdepold commented on Nov 16, 2015

    @sdepold
    Member

    Yep. Good idea. Want to file a PR?

  3. mjhea0 commented on Nov 16, 2015

    @mjhea0

    Can we wait to see the result of this PR #223

  4. mjhea0 commented on Nov 16, 2015

    @mjhea0

    Also, would you recommend using https://www.npmjs.com/package/yargs for validation?

  5. sdepold commented on Nov 17, 2015

    @sdepold
    Member

    Not sure tbh. Guess yargs is not the right tool for that. IIRC https://github.com/sequelize/cli/blob/master/lib/helpers/model-helper.js#L28 this should be the line where we have access to the attributes. split[1] should contain the data type

  6. AminTizdastAzar commented on Oct 8, 2017

    @AminTizdastAzar

    @sushantdhiman My OS is windows and when I try to run test there are bunch of errors like:
    9:5 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style

    By the way I fixed it but I don't know how to test it. Could you please give me the links to learns how to test it.
    Thanks

  7. added a commit that references this issue on Oct 23, 2017
    c432216
  8. pranavpr commented on Dec 13, 2017

    @pranavpr

    @sushantdhiman Can I work on this if no one is working on it?

  9. sushantdhiman commented on Aug 19, 2018

    @sushantdhiman
    Contributor

    Fixed by #682

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions