New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

obey

Package Overview
Dependencies
Maintainers
3
Versions
55
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

obey - npm Package Compare versions

Comparing version 0.11.0 to 0.11.1

12

build/lib/validators.js

@@ -67,14 +67,2 @@ 'use strict';

}
},
/**
* Validator requires method, used by model
* @param {Object} def The property configuration
* @param {String} key The key name of the property
* @param {*} value The value being validated
*/
required: function required(def, key, value) {
if (def.required && !value) {
this.errors.push({ type: 'required', sub: 'default', key: key, value: value, message: 'Property \'' + key + '\' is required' });
}
}

@@ -81,0 +69,0 @@ };

23

build/rules.js

@@ -33,7 +33,18 @@ 'use strict';

/**
* Defines all definition property checks available
*/
/*
* Copyright (c) 2015 TechnologyAdvice
*/
var allProps = {
generator: { name: 'generator', fn: _generators2.default.validator },
default: { name: 'default', fn: _validators2.default.default },
modifier: { name: 'modifier', fn: _modifiers2.default.validator },
allow: { name: 'allow', fn: _validators2.default.allow },
min: { name: 'min', fn: _validators2.default.min },
max: { name: 'max', fn: _validators2.default.max },
type: { name: 'type', fn: _types2.default.validator }
};
var rules = {

@@ -44,3 +55,8 @@ /**

*/
props: [{ name: 'generator', fn: _generators2.default.validator }, { name: 'default', fn: _validators2.default.default }, { name: 'modifier', fn: _modifiers2.default.validator }, { name: 'allow', fn: _validators2.default.allow }, { name: 'min', fn: _validators2.default.min }, { name: 'max', fn: _validators2.default.max }, { name: 'type', fn: _types2.default.validator }, { name: 'required', fn: _validators2.default.required }],
props: {
// Default props
default: [allProps.generator, allProps.default, allProps.modifier, allProps.allow, allProps.min, allProps.max, allProps.type],
// When no value/undefined
noVal: [allProps.generator, allProps.default, allProps.modifier]
},

@@ -65,5 +81,6 @@ /**

var context = { errors: [] };
var props = !def.required && data === undefined ? rules.props.noVal : rules.props.default;
if (!def.type) throw new Error('Model properties must define a \'type\'');
var chain = _bluebird2.default.resolve(data);
rules.props.forEach(function (prop) {
props.forEach(function (prop) {
if (def[prop.name]) {

@@ -70,0 +87,0 @@ chain = chain.then(prop.fn.bind(context, def, key)).then(function (res) {

{
"name": "obey",
"version": "0.11.0",
"version": "0.11.1",
"description": "Data modelling and validation library",

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

@@ -135,3 +135,3 @@ # Obey

* `max`: The maximum character length for a string, highest number, or maximum items in array
* `required`: Enforces the field cannot be missing during validation
* `required`: Enforces the field cannot be missing during validation (default `false`)
* `allow`: Array of allowed values or single allowed value

@@ -138,0 +138,0 @@ * `strict`: Enable or disable strict checking of an object, see [Strict Mode](#strict-mode)

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