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

optimal

Package Overview
Dependencies
Maintainers
1
Versions
68
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

optimal - npm Package Compare versions

Comparing version 4.0.0-1 to 4.0.0-2

lib/logUnknown.d.ts

45

esm/index.js

@@ -433,2 +433,11 @@ function _defineProperty(obj, key, value) {

function logUnknown(unknownFields, pathPrefix) {
var unknownKeys = Object.keys(unknownFields);
if (unknownKeys.length > 0) {
var message = pathPrefix ? "Unknown \"" + pathPrefix + "\" fields" : 'Unknown fields';
throw new Error(message + ": " + unknownKeys.join(', ') + ".");
}
}
var Schema = function () {

@@ -499,8 +508,3 @@ function Schema(blueprint) {

} else if ("production" !== process.env.NODE_ENV) {
var unknownKeys = Object.keys(unknownFields);
if (unknownKeys.length > 0) {
var message = pathPrefix ? "Unknown \"" + pathPrefix + "\" fields" : 'Unknown fields';
throw new Error(message + ": " + unknownKeys.join(', ') + ".");
}
logUnknown(unknownFields, pathPrefix);
}

@@ -1059,14 +1063,27 @@

_proto.run = function run(value, path, schema) {
var object = value || this.getDefaultValue() || {};
var _this2 = this;
if ("production" !== process.env.NODE_ENV) {
this.invariant(isObject(object), 'Value passed to shape must be an object.', path);
if ("production" !== process.env.NODE_ENV && value) {
this.invariant(isObject(value), 'Value passed to shape must be an object.', path);
}
return optimal(object, this.contents, {
file: schema.filePath,
name: schema.schemaName,
prefix: path,
unknown: !this.isExact
var unknownFields = _extends({}, value);
var struct = {};
Object.keys(this.contents).forEach(function (baseKey) {
var key = baseKey;
var content = _this2.contents[key];
struct[key] = content.run(value === null || value === void 0 ? void 0 : value[key], path + "." + key, schema);
delete unknownFields[key];
});
if (this.isExact) {
if ("production" !== process.env.NODE_ENV) {
logUnknown(unknownFields, path);
}
} else {
Object.assign(struct, unknownFields);
}
return struct;
};

@@ -1073,0 +1090,0 @@

@@ -437,2 +437,11 @@ 'use strict';

function logUnknown(unknownFields, pathPrefix) {
var unknownKeys = Object.keys(unknownFields);
if (unknownKeys.length > 0) {
var message = pathPrefix ? "Unknown \"" + pathPrefix + "\" fields" : 'Unknown fields';
throw new Error(message + ": " + unknownKeys.join(', ') + ".");
}
}
var Schema = function () {

@@ -503,8 +512,3 @@ function Schema(blueprint) {

} else if ("production" !== process.env.NODE_ENV) {
var unknownKeys = Object.keys(unknownFields);
if (unknownKeys.length > 0) {
var message = pathPrefix ? "Unknown \"" + pathPrefix + "\" fields" : 'Unknown fields';
throw new Error(message + ": " + unknownKeys.join(', ') + ".");
}
logUnknown(unknownFields, pathPrefix);
}

@@ -1063,14 +1067,27 @@

_proto.run = function run(value, path, schema) {
var object = value || this.getDefaultValue() || {};
var _this2 = this;
if ("production" !== process.env.NODE_ENV) {
this.invariant(isObject(object), 'Value passed to shape must be an object.', path);
if ("production" !== process.env.NODE_ENV && value) {
this.invariant(isObject(value), 'Value passed to shape must be an object.', path);
}
return optimal(object, this.contents, {
file: schema.filePath,
name: schema.schemaName,
prefix: path,
unknown: !this.isExact
var unknownFields = _extends({}, value);
var struct = {};
Object.keys(this.contents).forEach(function (baseKey) {
var key = baseKey;
var content = _this2.contents[key];
struct[key] = content.run(value === null || value === void 0 ? void 0 : value[key], path + "." + key, schema);
delete unknownFields[key];
});
if (this.isExact) {
if ("production" !== process.env.NODE_ENV) {
logUnknown(unknownFields, path);
}
} else {
Object.assign(struct, unknownFields);
}
return struct;
};

@@ -1077,0 +1094,0 @@

@@ -66,3 +66,3 @@ import Schema from './Schema';

*/
required(state?: boolean): Predicate<NonNullable<T>>;
required(state?: boolean): this;
/**

@@ -108,3 +108,3 @@ * Run all validation checks that have been enqueued and return a type casted value.

}
export declare function custom<T, S extends object = object>(callback: CustomCallback<T, S>, defaultValue: DefaultValue<T>): Predicate<T>;
export declare function func<T = FuncOf>(defaultValue?: T | null): Predicate<T | null>;
export declare function custom<T, S extends object = {}>(callback: CustomCallback<T, S>, defaultValue: DefaultValue<T>): Predicate<T>;
export declare function func<T extends FuncOf = FuncOf>(defaultValue?: T | null): Predicate<T | null>;

@@ -9,4 +9,4 @@ import Predicate from '../Predicate';

exact(): this;
run(value: T | undefined, path: string, schema: Schema<{}>): Required<T>;
run(value: T | undefined, path: string, schema: Schema<{}>): T;
}
export declare function shape<T extends object>(contents: Blueprint<T>): ShapePredicate<T>;
{
"name": "optimal",
"version": "4.0.0-1",
"version": "4.0.0-2",
"description": "A system for building and validating defined object structures.",

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

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