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

legalize

Package Overview
Dependencies
Maintainers
3
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

legalize - npm Package Compare versions

Comparing version 1.0.0 to 1.2.0

5

bower.json
{
"name": "legalize",
"main": "legalize.js",
"version": "1.0.0",
"version": "1.2.0",
"homepage": "https://github.com/paypal/legalize.js",
"authors": [
"Julian Fleischer <julfleischer@paypal.com>"
"Julian Fleischer",
"Jenny Warnke"
],

@@ -9,0 +10,0 @@ "description": "A javascript object validation library.",

6

Gruntfile.js

@@ -36,3 +36,3 @@ /*───────────────────────────────────────────────────────────────────────────*\

src: [
"src/**/*.js",
"src/**/*.js"
],

@@ -65,3 +65,3 @@ gruntfile: [

options: {
compress: true,
compress: { warnings: false },
report: "gzip",

@@ -136,3 +136,3 @@ preserveComments: "some",

["jshint"]);
grunt.registerTask("test",

@@ -139,0 +139,0 @@ ["lint", "mochaTest:test"]);

@@ -11,5 +11,7 @@ Hacking on Legalize.js

repository (this is to distribute the browser version via bower).
- `src/legalize.js` contains the main library.
- `src/legalize-browser.js` only contains browser specific tweaks such as shims
needed to make it compatible with various browsers out there.
- The release artifact is assembled via `preprocess`, so check out the
documentation: https://github.com/jsoverson/preprocess

@@ -23,8 +23,15 @@ /*───────────────────────────────────────────────────────────────────────────*\

if (typeof define === 'function' && define.amd) {
define('Legalize', factory);
var legalize = factory();
// set globally for use with plain javascript
if (typeof window !== "undefined") {
window.Legalize = legalize;
} else {
window.Legalize = factory();
this.Legalize = legalize;
}
// define module for use with requireJs
if (typeof define === "function" && define.amd) {
define("Legalize", [], legalize);
}
}(function (undefined) {

@@ -43,5 +50,5 @@ "use strict";

}
var ES5Object = {
freeze: isFunc(Object.freeze) ? Object.freeze : function (x) {

@@ -56,3 +63,3 @@ // Object.freeze is used to freeze the publicly exposed API.

keys: isFunc(Object.keys) ? Object.keys : (function() {
keys: isFunc(Object.keys) ? Object.keys : (function () {
// Object.keys() is not available in some legacy browsers.

@@ -63,15 +70,15 @@ // This shim is taken (and slightly modified to make jshint happy) from

var hasOwnProperty = Object.prototype.hasOwnProperty;
var hasDontEnumBug = !({ toString: null }).propertyIsEnumerable('toString');
var hasDontEnumBug = !({toString: null}).propertyIsEnumerable('toString');
var dontEnums = [
'toString',
'toLocaleString',
'valueOf',
'hasOwnProperty',
'isPrototypeOf',
'propertyIsEnumerable',
'constructor'
];
'toString',
'toLocaleString',
'valueOf',
'hasOwnProperty',
'isPrototypeOf',
'propertyIsEnumerable',
'constructor'
];
var dontEnumsLength = dontEnums.length;
return function(obj) {
return function (obj) {
var result = [], prop, i;

@@ -107,3 +114,4 @@

return (function (Object) {
var Legalize = (function (Object) {
// the `Object` argument overloads the actual `Object` in legacy

@@ -115,2 +123,3 @@ // browser engines. legalize uses exactly the functions defined

/* jshint unused: false */
var _Legalize = window.Legalize;

@@ -150,2 +159,8 @@ /*───────────────────────────────────────────────────────────────────────────*\

}
function noConflict() {
if (window.Legalize === Legalize) {
window.Legalize = _Legalize;
}
return Legalize;
}
function cast(value, type) {

@@ -472,3 +487,3 @@ if (typeOf(value) === type) {

actual = String(actual);
return actual.toUpperCase() === actual;
return actual.toUpperCase() === actual;
}),

@@ -517,3 +532,3 @@

}, withLengthChecks({
keys: makeProperty("keys"),

@@ -548,3 +563,3 @@

}
// if the given options are not empty, validate 'em

@@ -562,4 +577,4 @@ // the check is necessary as we would be calling ourselves

// compile the schema - compile will check, whether schema is already
// compiled.
// compile the schema - compile will check whether schema is
// already compiled.
schema = compile(schema);

@@ -571,7 +586,7 @@

// A helper that is recursively applied along the object.
//
//
// Returns the validated value (or the default, if there is one,
// in case the validation failed).
function _validate(value, schema, path) {
// calculate the type of the value - see `typeOf`.

@@ -606,3 +621,3 @@ var actualType = typeOf(value);

}
// creates an errorneous return value

@@ -648,3 +663,3 @@ function makeError(validValue, error, expected, actual) {

// - `value` is not undefined
// if FORBIDDEN we're facing a situation here:

@@ -731,3 +746,3 @@ if (presence === FORBIDDEN) {

// - `value` is not in the set of `invalid` values
// iterate over all checks and check whether the value satisfies them or not

@@ -761,3 +776,3 @@ var checksFailed = [];

if (expectedType === 'object') {
var validObject = {};

@@ -798,3 +813,3 @@ var objectErrors = [];

});
if (!isEmpty(objectErrors)) {

@@ -810,3 +825,3 @@ return makeError(validObject, objectErrors);

else if (expectedType === 'array') {
var validArray = [];

@@ -958,3 +973,4 @@ var arrayErrors = [];

typeOf: typeOf
typeOf: typeOf,
noConflict: noConflict
});

@@ -989,7 +1005,10 @@

/* global publiclyExposedInterface */
return publiclyExposedInterface;
return publiclyExposedInterface;
}(ES5Object));
return Legalize;
}));
{
"name": "legalize",
"version": "1.0.0",
"version": "1.2.0",
"description": "A library for performing object-validation in the browser as in node",
"author": "Julian Fleischer <julfleischer@paypal.com>",
"author": "Julian Fleischer, Jenny Warnke",
"main": "./src/legalize-node.js",

@@ -7,0 +7,0 @@ "bin": "legalize.js",

# Legalize.js
[![Build Status](https://travis-ci.org/paypal/legalize.js.svg)](https://travis-ci.org/paypal/legalize.js)
Lead Maintainer: [Jenny Warnke](https://github.com/jewar)
[![Build Status](https://travis-ci.org/paypal/legalize.js.svg?branch=master)](https://travis-ci.org/paypal/legalize.js)
Legalize.js is a library that performs validation of domain objects.

@@ -6,0 +8,0 @@ It does **not** perform validation of web forms. It is optimized for the

@@ -23,8 +23,15 @@ /*───────────────────────────────────────────────────────────────────────────*\

if (typeof define === 'function' && define.amd) {
define('Legalize', factory);
var legalize = factory();
// set globally for use with plain javascript
if (typeof window !== "undefined") {
window.Legalize = legalize;
} else {
window.Legalize = factory();
this.Legalize = legalize;
}
// define module for use with requireJs
if (typeof define === "function" && define.amd) {
define("Legalize", [], legalize);
}
}(function (undefined) {

@@ -43,5 +50,5 @@ "use strict";

}
var ES5Object = {
freeze: isFunc(Object.freeze) ? Object.freeze : function (x) {

@@ -56,3 +63,3 @@ // Object.freeze is used to freeze the publicly exposed API.

keys: isFunc(Object.keys) ? Object.keys : (function() {
keys: isFunc(Object.keys) ? Object.keys : (function () {
// Object.keys() is not available in some legacy browsers.

@@ -63,15 +70,15 @@ // This shim is taken (and slightly modified to make jshint happy) from

var hasOwnProperty = Object.prototype.hasOwnProperty;
var hasDontEnumBug = !({ toString: null }).propertyIsEnumerable('toString');
var hasDontEnumBug = !({toString: null}).propertyIsEnumerable('toString');
var dontEnums = [
'toString',
'toLocaleString',
'valueOf',
'hasOwnProperty',
'isPrototypeOf',
'propertyIsEnumerable',
'constructor'
];
'toString',
'toLocaleString',
'valueOf',
'hasOwnProperty',
'isPrototypeOf',
'propertyIsEnumerable',
'constructor'
];
var dontEnumsLength = dontEnums.length;
return function(obj) {
return function (obj) {
var result = [], prop, i;

@@ -107,3 +114,4 @@

return (function (Object) {
var Legalize = (function (Object) {
// the `Object` argument overloads the actual `Object` in legacy

@@ -115,9 +123,13 @@ // browser engines. legalize uses exactly the functions defined

/* jshint unused: false */
var _Legalize = window.Legalize;
// @include legalize.js
/* global publiclyExposedInterface */
return publiclyExposedInterface;
return publiclyExposedInterface;
}(ES5Object));
return Legalize;
}));

@@ -20,3 +20,3 @@ /*───────────────────────────────────────────────────────────────────────────*\

/* global window */
/* global window, Legalize, _Legalize */
// @endexclude

@@ -41,2 +41,8 @@

}
function noConflict() {
if (window.Legalize === Legalize) {
window.Legalize = _Legalize;
}
return Legalize;
}
function cast(value, type) {

@@ -363,3 +369,3 @@ if (typeOf(value) === type) {

actual = String(actual);
return actual.toUpperCase() === actual;
return actual.toUpperCase() === actual;
}),

@@ -408,3 +414,3 @@

}, withLengthChecks({
keys: makeProperty("keys"),

@@ -439,3 +445,3 @@

}
// if the given options are not empty, validate 'em

@@ -453,4 +459,4 @@ // the check is necessary as we would be calling ourselves

// compile the schema - compile will check, whether schema is already
// compiled.
// compile the schema - compile will check whether schema is
// already compiled.
schema = compile(schema);

@@ -462,7 +468,7 @@

// A helper that is recursively applied along the object.
//
//
// Returns the validated value (or the default, if there is one,
// in case the validation failed).
function _validate(value, schema, path) {
// calculate the type of the value - see `typeOf`.

@@ -497,3 +503,3 @@ var actualType = typeOf(value);

}
// creates an errorneous return value

@@ -539,3 +545,3 @@ function makeError(validValue, error, expected, actual) {

// - `value` is not undefined
// if FORBIDDEN we're facing a situation here:

@@ -622,3 +628,3 @@ if (presence === FORBIDDEN) {

// - `value` is not in the set of `invalid` values
// iterate over all checks and check whether the value satisfies them or not

@@ -652,3 +658,3 @@ var checksFailed = [];

if (expectedType === 'object') {
var validObject = {};

@@ -689,3 +695,3 @@ var objectErrors = [];

});
if (!isEmpty(objectErrors)) {

@@ -701,3 +707,3 @@ return makeError(validObject, objectErrors);

else if (expectedType === 'array') {
var validArray = [];

@@ -849,3 +855,4 @@ var arrayErrors = [];

typeOf: typeOf
typeOf: typeOf,
noConflict: noConflict
});

@@ -852,0 +859,0 @@

@@ -104,3 +104,3 @@ /*───────────────────────────────────────────────────────────────────────────*\

});
it (which + "()." + key + " chained should still be a function", function () {

@@ -107,0 +107,0 @@ expect(L[which]()[key]()[key]).to.be.a('function');

@@ -29,3 +29,3 @@ /*───────────────────────────────────────────────────────────────────────────*\

describe("error reporting", function () {
describe("custom error reporting", function () {

@@ -32,0 +32,0 @@ it("does propagate a custom warning from check() functions", function () {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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