This repository has been archived by the owner on Mar 20, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 867
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
57 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,15 @@ | ||
'use strict'; | ||
import isObject from 'lodash/lang/isObject'; | ||
|
||
var isObject = require('lodash/lang/isObject'); | ||
export default class ArraySchema { | ||
constructor(itemSchema) { | ||
if (!isObject(itemSchema)) { | ||
throw new Error('ArraySchema requires item schema to be an object.'); | ||
} | ||
|
||
function ArraySchema(itemSchema) { | ||
if (!isObject(itemSchema)) { | ||
throw new Error('ArraySchema requires item schema to be an object.'); | ||
this._itemSchema = itemSchema; | ||
} | ||
|
||
this._itemSchema = itemSchema; | ||
getItemSchema() { | ||
return this._itemSchema; | ||
} | ||
} | ||
|
||
ArraySchema.prototype.getItemSchema = function () { | ||
return this._itemSchema; | ||
}; | ||
|
||
module.exports = ArraySchema; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,26 @@ | ||
'use strict'; | ||
export default class EntitySchema { | ||
constructor(key, options = {}) { | ||
if (!key || typeof key !== 'string') { | ||
throw new Error('A string non-empty key is required'); | ||
} | ||
|
||
function EntitySchema(key, options) { | ||
if (!key || typeof key !== 'string') { | ||
throw new Error('A string non-empty key is required'); | ||
this._idAttribute = options.idAttribute || 'id'; | ||
this._key = key; | ||
} | ||
|
||
options = options || {}; | ||
|
||
this._idAttribute = options.idAttribute || 'id'; | ||
this._key = key; | ||
} | ||
|
||
EntitySchema.prototype.getKey = function () { | ||
return this._key; | ||
}; | ||
getKey() { | ||
return this._key; | ||
} | ||
|
||
EntitySchema.prototype.getIdAttribute = function () { | ||
return this._idAttribute; | ||
}; | ||
getIdAttribute() { | ||
return this._idAttribute; | ||
} | ||
|
||
EntitySchema.prototype.define = function (nestedSchema) { | ||
for (var key in nestedSchema) { | ||
if (nestedSchema.hasOwnProperty(key)) { | ||
this[key] = nestedSchema[key]; | ||
define(nestedSchema) { | ||
for (let key in nestedSchema) { | ||
if (nestedSchema.hasOwnProperty(key)) { | ||
this[key] = nestedSchema[key]; | ||
} | ||
} | ||
} | ||
}; | ||
|
||
module.exports = EntitySchema; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters