Skip to content

Instantly share code, notes, and snippets.

@broofa
Last active January 31, 2020 15:32
Show Gist options
  • Select an option

  • Save broofa/2d85e249d219406e54ab14b3c8f4f36c to your computer and use it in GitHub Desktop.

Select an option

Save broofa/2d85e249d219406e54ab14b3c8f4f36c to your computer and use it in GitHub Desktop.

Revisions

  1. broofa revised this gist Jan 31, 2020. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions sequelize_validate_issue.js
    Original file line number Diff line number Diff line change
    @@ -12,16 +12,16 @@ async function main() {
    aColumn: {
    type: Sequelize.STRING,
    allowNull: true,
    defaultValue: null,
    validate: {
    customValidator() {
    throw Error('This should not run!');
    throw Error('Why is this being run???');
    }
    }
    }
    }, {timestamps: false});

    const thing = Thing.create();
    // This throws. It shouldn't.
    await Thing.create();
    }

    main();
  2. broofa renamed this gist Jan 31, 2020. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  3. broofa created this gist Jan 31, 2020.
    27 changes: 27 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,27 @@
    const Sequelize = require('sequelize');

    async function main() {
    const sequelize = new Sequelize(null, null, null, {
    dialect: 'sqlite',
    storage: ':memory:',
    });

    await sequelize.query('CREATE TABLE things (id INTEGER PRIMARY KEY, aColumn TEXT DEFAULT NULL)');

    const Thing = await sequelize.define('thing', {
    aColumn: {
    type: Sequelize.STRING,
    allowNull: true,
    defaultValue: null,
    validate: {
    customValidator() {
    throw Error('This should not run!');
    }
    }
    }
    }, {timestamps: false});

    const thing = Thing.create();
    }

    main();