Socket
Socket
Sign inDemoInstall

bookshelf-modelbase

Package Overview
Dependencies
Maintainers
2
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bookshelf-modelbase - npm Package Compare versions

Comparing version 0.0.0 to 0.1.0

14

lib/index.js

@@ -12,3 +12,13 @@ var _ = require('lodash');

initialize: function (attrs, options) {
this.validation || (this.validation = Joi.any());
if (this.validate) {
this.validate = Joi.object(this.validate).keys({
// id might be number or string, for optimization
id: Joi.any().required(),
createdAt: Joi.date().required(),
updatedAt: Joi.date().required()
})
} else {
this.validate = Joi.object({ n: Joi.string().required() });
}
this.validate || (this.validate = Joi.any());
this.on('saving', this.validateSave);

@@ -20,3 +30,3 @@ },

validateSave: function () {
var validation = Joi.validate(this.attributes, this.validation);
var validation = Joi.validate(this.attributes, this.validate);
if (validation.errors) {

@@ -23,0 +33,0 @@ throw new Error(validation.errors);

2

package.json
{
"name": "bookshelf-modelbase",
"version": "0.0.0",
"version": "0.1.0",
"description": "Extensible ModelBase for bookshelf-based model layers",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

@@ -41,4 +41,7 @@ ModelBase ![Build Status](https://travis-ci.org/bsiddiqui/bookshelf-modelbase.svg?branch=master)

}, {
validation: <Joi validation object, defaults to Joi.any()>
// validation is passed to Joi.object(), so use a raw object
validation: {
firstName: Joi.string()
}
})
```

@@ -26,3 +26,3 @@ var Joi = require('joi');

it('should convert snake case to camel case', function () {
expect(specimen.parse({ variable_name: 'snake_case' }))
return expect(specimen.parse({ variable_name: 'snake_case' }))
.to.eql({ variableName: 'snake_case' })

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

it('should convert camel case to snake case', function () {
expect(specimen.format({ variableName: 'snake_case' }))
return expect(specimen.format({ variableName: 'snake_case' }))
.to.eql({ variable_name: 'snake_case' })

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

it('should validate own attributes', function () {
expect(specimen.validateSave()).to.contain({
return expect(specimen.validateSave()).to.contain({
name: 'hello'

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

it('should itself be extensible', function () {
expect(ModelBase.extend({ tableName: 'test' }))
return expect(ModelBase.extend({ tableName: 'test' }))
.to.itself.respondTo('extend');

@@ -57,0 +57,0 @@ });

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc