Add warning for validations in schema.js
This commit is contained in:
parent
8dafb424ed
commit
87a8172b82
|
@ -43,6 +43,21 @@ railway.orm._schemas.forEach(function (schema) {
|
|||
schema.freeze();
|
||||
});
|
||||
|
||||
// check validations and display warning
|
||||
|
||||
var displayWarning = false;
|
||||
Object.keys(app.models).forEach(function (model) {
|
||||
var Model = app.models[model];
|
||||
if (Model._validations) {
|
||||
displayWarning = true;
|
||||
}
|
||||
});
|
||||
|
||||
if (displayWarning) {
|
||||
var $ = railway.utils.stylize.$;
|
||||
require('util').puts($('WARNING:').bold.red + ' ' + $('I can see that you\'ve added validation to db/schema.js. However schema.js file is only used to describe database schema. Therefore validations configured in db/schema.js will be ignored.\nFor business logic (incl. validations) please create models as separate .js files here: app/models/*.js').yellow);
|
||||
}
|
||||
|
||||
function log(str, startTime) {
|
||||
var $ = railway.utils.stylize.$;
|
||||
var m = Date.now() - startTime;
|
||||
|
|
Loading…
Reference in New Issue