Skip to content

Commit

Permalink
Throw a validation error when properties passed to validator aren't a…
Browse files Browse the repository at this point in the history
…n Object
  • Loading branch information
adam-cowley committed Jul 27, 2018
1 parent f429953 commit 1b8edae
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
8 changes: 8 additions & 0 deletions build/Services/GenerateDefaultValues.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ var _uuid = require('uuid');

var _uuid2 = _interopRequireDefault(_uuid);

var _ValidationError = require('../ValidationError');

var _ValidationError2 = _interopRequireDefault(_ValidationError);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

/**
Expand Down Expand Up @@ -55,6 +59,10 @@ function GenerateDefaultValues(neode, model, properties) {
var schema = model.schema();
var output = {};

if (!properties instanceof Object) {
throw new _ValidationError2.default('`properties` must be an object.', properties);
}

// Get All Config
Object.keys(schema).forEach(function (key) {
var config = typeof schema[key] == 'string' ? { type: schema[key] } : schema[key];
Expand Down
5 changes: 5 additions & 0 deletions src/Services/GenerateDefaultValues.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import uuid from 'uuid';
import ValidationError from '../ValidationError';

/**
* Convert a value to it's native type
Expand Down Expand Up @@ -44,6 +45,10 @@ export default function GenerateDefaultValues(neode, model, properties) {
const schema = model.schema();
const output = {};

if ( !properties instanceof Object ) {
throw new ValidationError('`properties` must be an object.', properties);
}

// Get All Config
Object.keys(schema).forEach(key => {
const config = typeof schema[ key ] == 'string' ? {type: schema[ key ]} : schema[ key ];
Expand Down

0 comments on commit 1b8edae

Please sign in to comment.