Add warning for validations in schema.js

This commit is contained in:
Anatoliy Chakkaev 2012-04-10 01:28:14 +04:00
parent 8dafb424ed
commit 87a8172b82
1 changed files with 15 additions and 0 deletions

View File

@ -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;