Skip to content

Commit 8bb97a4

Browse files
committed
Improve modelate
1 parent 55288b1 commit 8bb97a4

File tree

3 files changed

+6
-10
lines changed

3 files changed

+6
-10
lines changed

lib/model.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,7 @@ const models = {};
33
function model(data) {
44
// ToDo: Validate model
55
// ToDo: Check if model already exists to merge instead of set
6-
// for(let prop in data) {
7-
// if(data[prop].model) {
8-
// data[prop] = models[data[prop].model];
9-
// }
10-
// }
11-
6+
127
models[this.modelName] = data;
138

149
return this;

lib/validators/model.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
var util = require('../util');
22
var models = require('../model').models;
3-
// var validate = require('../validate');
43

54
/**
6-
* Type validator
5+
* Model validator
76
*
87
* {
9-
* type: String // Check if data has a JS type (uses typeof)
8+
* model: String // Check if data has a model type
109
* }
1110
*/
1211
function isValid(data, model) {
@@ -17,11 +16,13 @@ function isValid(data, model) {
1716
var validate = module.parent.parent.exports;
1817
var valid = validate(data, {model: models[model.model]});
1918

19+
// Return if data is of model's type.
2020
// var eq = util.equal(data, valid);
2121
// return eq;
2222

2323
// Turn data into a valid model...
2424
reference(data, valid);
25+
// And return true (data is parsed, so data is modelated)
2526
return true;
2627
}
2728

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "modelate",
3-
"version": "0.1.0",
3+
"version": "0.2.0",
44
"description": "A simple data modeling tool for NodeJS",
55
"main": "index.js",
66
"scripts": {

0 commit comments

Comments
 (0)