Skip to content

Commit

Permalink
Add types verification fix error
Browse files Browse the repository at this point in the history
  • Loading branch information
dionmaicon committed Dec 12, 2019
1 parent 2c216a1 commit b1eeebb
Showing 1 changed file with 26 additions and 27 deletions.
53 changes: 26 additions & 27 deletions js/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,33 +106,32 @@ const Types = class {
};

for (let prop in model) {
if (model.hasOwnProperty(prop)) {
let object = model[prop];
switch (model[prop].type) {
case Types.ONE_TO_ONE:
case Types.ONE_TO_MANY:
if (!object.attribute) {
response.message += `Model type: ${prop} needs attribute property.\n`;
response.success = false;
}
if (!object.model) {
response.message += `Model type: ${prop} needs model property.\n`;
response.success = false;
}
break;
case Types.RADIO:
case Types.CHECKBOX:
case Types.SELECT:
if (!object.options) {
response.message += `Model type: ${prop} needs options property.\n`;
response.success = false;
}
break;
}
if (!this.isValid(model[prop].type)) {
response.message += `Model type: ${prop} is invalid.\n`;
response.success = false;
}
if (!model.hasOwnProperty(prop)) continue;
let object = model[prop];
switch (model[prop].type) {
case Types.ONE_TO_ONE:
case Types.ONE_TO_MANY:
if (!object.attribute) {
response.message += `Model type: ${prop} needs attribute property.\n`;
response.success = false;
}
if (!object.model) {
response.message += `Model type: ${prop} needs model property.\n`;
response.success = false;
}
break;
case Types.RADIO:
case Types.CHECKBOX:
case Types.SELECT:
if (!object.options) {
response.message += `Model type: ${prop} needs options property.\n`;
response.success = false;
}
break;
}
if (!this.isValid(model[prop].type)) {
response.message += `Model type: ${prop} is invalid.\n`;
response.success = false;
}
}

Expand Down

0 comments on commit b1eeebb

Please sign in to comment.