2016-06-21 8 views

Antwort

1

Die Skriptausführung wird beendet, sobald Sie einen Fehler ausgeben.

Bei http://docs.sequelizejs.com/en/latest/docs/models-definition/, die Autoren von Sequelize.js dieses Beispiel:

var ValidateMe = sequelize.define('foo', { 
    foo: { 
    type: Sequelize.STRING, 
    validate: { 
     // custom validations are also possible: 
     isEven: function(value) { 
     if(parseInt(value) % 2 != 0) { 
      // This error will stop code execution and give you the chance to catch and handle the error 
      throw new Error('Only even values are allowed!') 
     // we also are in the model's context here, so this.otherField 
     // would get the value of otherField if it existed 
     } 
     } 
    } 
    } 
});