From 82dd8f33f89894bf8f58aa37263a30b63a1f9081 Mon Sep 17 00:00:00 2001 From: Mathew Henson Date: Wed, 27 Apr 2016 15:36:19 +0100 Subject: [PATCH] Removed unnecessary code --- .../src/models/schema-items/schema-bool.js | 15 +++++---------- .../src/models/schema-items/schema-date.js | 7 ++++--- .../src/models/schema-items/schema-html.js | 7 ------- .../src/models/schema-items/schema-id-array.js | 7 ------- .../dist/src/models/schema-items/schema-id.js | 10 ---------- .../src/models/schema-items/schema-json.js | 7 ------- .../models/schema-items/schema-num-array.js | 7 ------- .../src/models/schema-items/schema-number.js | 7 ------- .../models/schema-items/schema-text-array.js | 7 ------- .../src/models/schema-items/schema-text.js | 7 ------- server/src/models/schema-items/schema-bool.ts | 18 ++++++------------ server/src/models/schema-items/schema-date.ts | 8 +++++--- server/src/models/schema-items/schema-html.ts | 10 +--------- .../src/models/schema-items/schema-id-array.ts | 10 +--------- server/src/models/schema-items/schema-id.ts | 13 +------------ server/src/models/schema-items/schema-json.ts | 10 +--------- .../models/schema-items/schema-num-array.ts | 10 +--------- .../src/models/schema-items/schema-number.ts | 10 +--------- .../models/schema-items/schema-text-array.ts | 10 +--------- server/src/models/schema-items/schema-text.ts | 10 +--------- 20 files changed, 28 insertions(+), 162 deletions(-) diff --git a/server/dist/src/models/schema-items/schema-bool.js b/server/dist/src/models/schema-items/schema-bool.js index a43900e6..59c45c96 100644 --- a/server/dist/src/models/schema-items/schema-bool.js +++ b/server/dist/src/models/schema-items/schema-bool.js @@ -33,18 +33,13 @@ var SchemaBool = (function (_super) { * @returns {boolean | string} Returns true if successful or an error message string if unsuccessful */ SchemaBool.prototype.validate = function () { - var val = _super.prototype.validate.call(this); - if (!val) - return false; + var val = this.value; + if (val === undefined) + return this.name + " cannot be undefined"; + if (val === null) + return this.name + " cannot be null"; return true; }; - /** - * Gets the value of this item - * @returns {boolean} - */ - SchemaBool.prototype.getValue = function () { - return this.value; - }; return SchemaBool; }(schema_item_1.SchemaItem)); exports.SchemaBool = SchemaBool; diff --git a/server/dist/src/models/schema-items/schema-date.js b/server/dist/src/models/schema-items/schema-date.js index 00e69f79..f7aa3c99 100644 --- a/server/dist/src/models/schema-items/schema-date.js +++ b/server/dist/src/models/schema-items/schema-date.js @@ -43,10 +43,11 @@ var SchemaDate = (function (_super) { }; /** * Gets the value of this item - * @returns {SchemaValue} + * @param {ISchemaOptions} options [Optional] A set of options that can be passed to control how the data must be returned + * @returns {number} */ - SchemaDate.prototype.getValue = function () { - return (this.value !== undefined && this.value !== null ? this.value : Date.now()); + SchemaDate.prototype.getValue = function (options) { + return (this.value !== undefined && this.value !== null ? this.value : null); }; return SchemaDate; }(schema_item_1.SchemaItem)); diff --git a/server/dist/src/models/schema-items/schema-html.js b/server/dist/src/models/schema-items/schema-html.js index bb11ca29..a4a8ca61 100644 --- a/server/dist/src/models/schema-items/schema-html.js +++ b/server/dist/src/models/schema-items/schema-html.js @@ -70,13 +70,6 @@ var SchemaHtml = (function (_super) { return true; }; /** - * Gets the value of this item - * @returns {SchemaValue} - */ - SchemaHtml.prototype.getValue = function () { - return this.value; - }; - /** * The default tags allowed * includes: h3, h4, h5, h6, blockquote, p, a, ul, ol, * nl, li, b, i, strong, em, strike, code, hr, br, div, diff --git a/server/dist/src/models/schema-items/schema-id-array.js b/server/dist/src/models/schema-items/schema-id-array.js index 19d65d1e..7890968d 100644 --- a/server/dist/src/models/schema-items/schema-id-array.js +++ b/server/dist/src/models/schema-items/schema-id-array.js @@ -60,13 +60,6 @@ var SchemaIdArray = (function (_super) { return "You have selected too many items for " + this.name + ", please only use up to " + this.maxItems; return true; }; - /** - * Gets the value of this item - * @returns {Array} - */ - SchemaIdArray.prototype.getValue = function () { - return this.value; - }; return SchemaIdArray; }(schema_item_1.SchemaItem)); exports.SchemaIdArray = SchemaIdArray; diff --git a/server/dist/src/models/schema-items/schema-id.js b/server/dist/src/models/schema-items/schema-id.js index 85b3d8bb..476ce283 100644 --- a/server/dist/src/models/schema-items/schema-id.js +++ b/server/dist/src/models/schema-items/schema-id.js @@ -50,16 +50,6 @@ var SchemaId = (function (_super) { } return true; }; - /** - * Gets the value of this item - * @returns {SchemaValue} - */ - SchemaId.prototype.getValue = function () { - if (!this.value) - return null; - else - return this.value; - }; return SchemaId; }(schema_item_1.SchemaItem)); exports.SchemaId = SchemaId; diff --git a/server/dist/src/models/schema-items/schema-json.js b/server/dist/src/models/schema-items/schema-json.js index 03148e1c..32949f85 100644 --- a/server/dist/src/models/schema-items/schema-json.js +++ b/server/dist/src/models/schema-items/schema-json.js @@ -37,13 +37,6 @@ var SchemaJSON = (function (_super) { this.value = null; return true; }; - /** - * Gets the value of this item - * @returns {SchemaValue} - */ - SchemaJSON.prototype.getValue = function () { - return this.value; - }; return SchemaJSON; }(schema_item_1.SchemaItem)); exports.SchemaJSON = SchemaJSON; diff --git a/server/dist/src/models/schema-items/schema-num-array.js b/server/dist/src/models/schema-items/schema-num-array.js index 13efadc9..458d56ca 100644 --- a/server/dist/src/models/schema-items/schema-num-array.js +++ b/server/dist/src/models/schema-items/schema-num-array.js @@ -81,13 +81,6 @@ var SchemaNumArray = (function (_super) { return "You have selected too many items for " + this.name + ", please only use up to " + this.maxItems; return true; }; - /** - * Gets the value of this item - * @returns {Array} - */ - SchemaNumArray.prototype.getValue = function () { - return this.value; - }; return SchemaNumArray; }(schema_item_1.SchemaItem)); exports.SchemaNumArray = SchemaNumArray; diff --git a/server/dist/src/models/schema-items/schema-number.js b/server/dist/src/models/schema-items/schema-number.js index 125caf76..6c4f6449 100644 --- a/server/dist/src/models/schema-items/schema-number.js +++ b/server/dist/src/models/schema-items/schema-number.js @@ -72,13 +72,6 @@ var SchemaNumber = (function (_super) { else return "The value of " + this.name + " is not within the range of " + this.min + " and " + this.max; }; - /** - * Gets the value of this item - * @returns {SchemaValue} - */ - SchemaNumber.prototype.getValue = function () { - return this.value; - }; return SchemaNumber; }(schema_item_1.SchemaItem)); exports.SchemaNumber = SchemaNumber; diff --git a/server/dist/src/models/schema-items/schema-text-array.js b/server/dist/src/models/schema-items/schema-text-array.js index 26a88a30..bf22efac 100644 --- a/server/dist/src/models/schema-items/schema-text-array.js +++ b/server/dist/src/models/schema-items/schema-text-array.js @@ -75,13 +75,6 @@ var SchemaTextArray = (function (_super) { } return true; }; - /** - * Gets the value of this item - * @returns {Array} - */ - SchemaTextArray.prototype.getValue = function () { - return this.value; - }; return SchemaTextArray; }(schema_item_1.SchemaItem)); exports.SchemaTextArray = SchemaTextArray; diff --git a/server/dist/src/models/schema-items/schema-text.js b/server/dist/src/models/schema-items/schema-text.js index 564bba83..14225885 100644 --- a/server/dist/src/models/schema-items/schema-text.js +++ b/server/dist/src/models/schema-items/schema-text.js @@ -64,13 +64,6 @@ var SchemaText = (function (_super) { else return true; }; - /** - * Gets the value of this item - * @returns {SchemaValue} - */ - SchemaText.prototype.getValue = function () { - return this.value; - }; return SchemaText; }(schema_item_1.SchemaItem)); exports.SchemaText = SchemaText; diff --git a/server/src/models/schema-items/schema-bool.ts b/server/src/models/schema-items/schema-bool.ts index 9beebf96..6ae159e0 100644 --- a/server/src/models/schema-items/schema-bool.ts +++ b/server/src/models/schema-items/schema-bool.ts @@ -1,4 +1,5 @@ import {SchemaItem} from "./schema-item"; +import {ISchemaOptions} from "modepress-api"; /** * A bool scheme item for use in Models @@ -33,19 +34,12 @@ export class SchemaBool extends SchemaItem */ public validate(): boolean | string { - var val = super.validate(); - if (!val) - return false; + var val = this.value; + if (val === undefined) + return `${this.name} cannot be undefined`; + if (val === null) + return `${this.name} cannot be null`; return true; } - - /** - * Gets the value of this item - * @returns {boolean} - */ - public getValue(): boolean - { - return this.value; - } } \ No newline at end of file diff --git a/server/src/models/schema-items/schema-date.ts b/server/src/models/schema-items/schema-date.ts index bd791763..2b1678b3 100644 --- a/server/src/models/schema-items/schema-date.ts +++ b/server/src/models/schema-items/schema-date.ts @@ -1,4 +1,5 @@ import {SchemaItem} from "./schema-item"; +import {ISchemaOptions} from "modepress-api"; /** * A date scheme item for use in Models @@ -46,10 +47,11 @@ export class SchemaDate extends SchemaItem /** * Gets the value of this item - * @returns {SchemaValue} + * @param {ISchemaOptions} options [Optional] A set of options that can be passed to control how the data must be returned + * @returns {number} */ - public getValue(): number + public getValue(options? : ISchemaOptions): number { - return (this.value !== undefined && this.value !== null ? this.value : Date.now() ); + return (this.value !== undefined && this.value !== null ? this.value : null ); } } \ No newline at end of file diff --git a/server/src/models/schema-items/schema-html.ts b/server/src/models/schema-items/schema-html.ts index 02efeb9a..e7eff2a6 100644 --- a/server/src/models/schema-items/schema-html.ts +++ b/server/src/models/schema-items/schema-html.ts @@ -1,4 +1,5 @@ import {SchemaItem} from "./schema-item"; +import {ISchemaOptions} from "modepress-api"; import sanitizeHtml = require("sanitize-html"); /** @@ -94,13 +95,4 @@ export class SchemaHtml extends SchemaItem this.value = sanitizedHTML; return true; } - - /** - * Gets the value of this item - * @returns {SchemaValue} - */ - public getValue(): string - { - return this.value; - } } \ No newline at end of file diff --git a/server/src/models/schema-items/schema-id-array.ts b/server/src/models/schema-items/schema-id-array.ts index 3850b03c..7eee6426 100644 --- a/server/src/models/schema-items/schema-id-array.ts +++ b/server/src/models/schema-items/schema-id-array.ts @@ -1,4 +1,5 @@ import {SchemaItem} from "./schema-item"; +import {ISchemaOptions} from "modepress-api"; import sanitizeHtml = require("sanitize-html"); import {ObjectID} from "mongodb"; import {Utils} from "../../utils" @@ -68,13 +69,4 @@ export class SchemaIdArray extends SchemaItem> return true; } - - /** - * Gets the value of this item - * @returns {Array} - */ - public getValue(): Array - { - return this.value; - } } \ No newline at end of file diff --git a/server/src/models/schema-items/schema-id.ts b/server/src/models/schema-items/schema-id.ts index 4156dec7..92dde4fd 100644 --- a/server/src/models/schema-items/schema-id.ts +++ b/server/src/models/schema-items/schema-id.ts @@ -1,4 +1,5 @@ import {SchemaItem} from "./schema-item"; +import {ISchemaOptions} from "modepress-api"; import {ObjectID} from "mongodb"; import {Utils} from "../../utils" @@ -55,16 +56,4 @@ export class SchemaId extends SchemaItem return true; } - - /** - * Gets the value of this item - * @returns {SchemaValue} - */ - public getValue(): ObjectID - { - if (!this.value) - return null; - else - return this.value; - } } \ No newline at end of file diff --git a/server/src/models/schema-items/schema-json.ts b/server/src/models/schema-items/schema-json.ts index 75eb4835..9b1f7532 100644 --- a/server/src/models/schema-items/schema-json.ts +++ b/server/src/models/schema-items/schema-json.ts @@ -1,4 +1,5 @@ import {SchemaItem} from "./schema-item"; +import {ISchemaOptions} from "modepress-api"; import sanitizeHtml = require("sanitize-html"); /** @@ -39,13 +40,4 @@ export class SchemaJSON extends SchemaItem return true; } - - /** - * Gets the value of this item - * @returns {SchemaValue} - */ - public getValue(): any - { - return this.value; - } } \ No newline at end of file diff --git a/server/src/models/schema-items/schema-num-array.ts b/server/src/models/schema-items/schema-num-array.ts index 3de24b9e..0ad995ee 100644 --- a/server/src/models/schema-items/schema-num-array.ts +++ b/server/src/models/schema-items/schema-num-array.ts @@ -1,4 +1,5 @@ import {SchemaItem} from "./schema-item"; +import {ISchemaOptions} from "modepress-api"; import {NumberType} from "./schema-number"; /** @@ -92,13 +93,4 @@ export class SchemaNumArray extends SchemaItem> return true; } - - /** - * Gets the value of this item - * @returns {Array} - */ - public getValue(): Array - { - return this.value; - } } \ No newline at end of file diff --git a/server/src/models/schema-items/schema-number.ts b/server/src/models/schema-items/schema-number.ts index c8a055cd..0e344019 100644 --- a/server/src/models/schema-items/schema-number.ts +++ b/server/src/models/schema-items/schema-number.ts @@ -1,4 +1,5 @@ import {SchemaItem} from "./schema-item"; +import {ISchemaOptions} from "modepress-api"; /** * Describes the type of number to store @@ -80,13 +81,4 @@ export class SchemaNumber extends SchemaItem else return `The value of ${this.name} is not within the range of ${this.min} and ${this.max}`; } - - /** - * Gets the value of this item - * @returns {SchemaValue} - */ - public getValue(): number - { - return this.value; - } } \ No newline at end of file diff --git a/server/src/models/schema-items/schema-text-array.ts b/server/src/models/schema-items/schema-text-array.ts index 1d36d43b..95b83ca5 100644 --- a/server/src/models/schema-items/schema-text-array.ts +++ b/server/src/models/schema-items/schema-text-array.ts @@ -1,4 +1,5 @@ import {SchemaItem} from "./schema-item"; +import {ISchemaOptions} from "modepress-api"; import sanitizeHtml = require("sanitize-html"); /** @@ -86,13 +87,4 @@ export class SchemaTextArray extends SchemaItem> return true; } - - /** - * Gets the value of this item - * @returns {Array} - */ - public getValue(): Array - { - return this.value; - } } \ No newline at end of file diff --git a/server/src/models/schema-items/schema-text.ts b/server/src/models/schema-items/schema-text.ts index 4b691369..bfe62582 100644 --- a/server/src/models/schema-items/schema-text.ts +++ b/server/src/models/schema-items/schema-text.ts @@ -1,4 +1,5 @@ import {SchemaItem} from "./schema-item"; +import {ISchemaOptions} from "modepress-api"; import sanitizeHtml = require("sanitize-html"); /** @@ -69,13 +70,4 @@ export class SchemaText extends SchemaItem else return true; } - - /** - * Gets the value of this item - * @returns {SchemaValue} - */ - public getValue(): string - { - return this.value; - } } \ No newline at end of file