Socket
Socket
Sign inDemoInstall

polyclay

Package Overview
Dependencies
3
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.6.3 to 1.6.4

34

lib/polyclay.js

@@ -89,3 +89,3 @@ var

name: 'string',
validatorFunc: function(item) { return _.isString(item) || (item == null); },
validatorFunc: _.isString,
defaultFunc: function() { return ''; }

@@ -104,3 +104,3 @@ });

name: 'number',
validatorFunc: function(item) { return _.isNumber(item) || (item == null); },
validatorFunc: _.isNumber,
defaultFunc: function() { return 0; }

@@ -112,3 +112,3 @@ });

name: 'boolean',
validatorFunc: function(item) { return _.isBoolean(item) || (item == null); },
validatorFunc: _.isBoolean,
defaultFunc: function() { return false; }

@@ -120,3 +120,3 @@ });

name: 'date',
validatorFunc: function(val) { return _.isDate(val) || isFinite(+val) || isFinite(new Date(val)); },
validatorFunc: function(val) { return isFinite(+val) || _.isDate(val) || isFinite(new Date(val)); },
defaultFunc: function() { return new Date(); }

@@ -128,3 +128,3 @@ });

name: 'hash',
validatorFunc: function(item) { return _.isObject(item) || (item === null); },
validatorFunc: _.isObject,
defaultFunc: function() { return {}; }

@@ -136,3 +136,3 @@ });

name: 'reference',
validatorFunc: function(item) { return _.isObject(item) || (item === null); },
validatorFunc: _.isObject,
defaultFunc: function() { return {}; }

@@ -158,3 +158,4 @@ });

p = props[i];
if (!PolyClay.validate[types[p]](this.__attributes[p]))
var val = this.__attributes[p];
if (val != null && !PolyClay.validate[types[p]](val))
{

@@ -198,3 +199,3 @@ this.errors[p] = 'invalid data';

if (this.__attributes[propname] === undefined)
return (this.__attributes[propname] = PolyClay.defaults(obj.prototype.__types[propname]));
return (this.__attributes[propname] = PolyClay.defaults(this.__types[propname]));

@@ -206,13 +207,14 @@ return this.__attributes[propname];

{
if ((obj.prototype.__types[propname] === 'string') && (newval == null))
newval = '';
var type = this.__types[propname];
if (newval == null)
newval = (type === 'string') ? '' : null;
else
{
if (!PolyClay.validate[type](newval))
throw(new Error(propname+': type of '+newval+' not '+type));
if (!PolyClay.validate[obj.prototype.__types[propname]](newval))
{
throw(new Error(propname+': type of '+newval+' not '+obj.prototype.__types[propname]));
if ((type === 'date') && !_.isDate(newval))
newval = new Date(newval);
}
if ((obj.prototype.__types[propname] === 'date') && !_.isDate(newval))
newval = new Date(newval);
this.__attributesPrev[propname] = this.__attributes[propname];

@@ -219,0 +221,0 @@ this.__attributes[propname] = newval;

{
"name": "polyclay",
"version": "1.6.3",
"version": "1.6.4",
"description": "a schema-enforcing model class for node with optional key-value store persistence",

@@ -5,0 +5,0 @@ "author": "C J Silverio <ceejceej@gmail.com>",

@@ -438,3 +438,3 @@ // Unit tests for the polyclay model framework.

it('complains about invalid data for unset properties', function()
it('does not complain about invalid data for unset properties', function()
{

@@ -444,4 +444,3 @@ instance.valid().should.not.be.ok;

assert(Object.keys(errors).length > 0, 'expected at least one error');
errors.should.have.property('created');
errors.created.should.equal('invalid data');
errors.should.not.have.property('created');
errors.should.not.have.property('foozles');

@@ -451,2 +450,13 @@ errors.should.not.have.property('name');

it('complains about type mismatches', function()
{
instance.__attributes.is_valid = 'no';
instance.valid().should.not.be.ok;
var errors = instance.errors;
assert(Object.keys(errors).length > 0, 'expected at least one error');
errors.should.have.property('is_valid');
errors.is_valid.should.equal('invalid data');
});
it('emits a valid JSON string even when properties are invalid', function()

@@ -453,0 +463,0 @@ {

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc