Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

schematized

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

schematized - npm Package Compare versions

Comparing version 1.8.4 to 1.8.5

7

CHANGELOG.md

@@ -0,1 +1,8 @@

## [1.8.5](https://github.com/ryparker/schematized/compare/v1.8.4...v1.8.5) (2020-08-13)
### Bug Fixes
* **max/min limits:** min/max were inaccurate if unset or 0 ([caa0fe6](https://github.com/ryparker/schematized/commit/caa0fe6d84f3e19cb248b8cc39fa612ed9ab4975))
## [1.8.4](https://github.com/ryparker/schematized/compare/v1.8.3...v1.8.4) (2020-08-13)

@@ -2,0 +9,0 @@

4

dist/strategies/number/maximum.d.ts
export declare class Maximum {
keywords: Set<string>;
max: number | null;
maximum: number | null;
addObject(number: number): void;
addSchema(schema: Record<string, any>): void;
toSchema(): {
maximum?: undefined;
} | {
maximum: number;
};
}

@@ -11,16 +11,24 @@ "use strict";

this.keywords = new Set(['maximum']);
this.max = null;
this.maximum = null;
}
addObject(number) {
this.max = lodash_1.default.isNil(this.max) ? number : Math.max(this.max, number);
this.maximum = lodash_1.default.isNil(this.maximum)
? number
: Math.max(this.maximum, number);
}
addSchema(schema) {
if (schema.maximum) {
this.max = Math.max(this.max, schema.maximum);
if (lodash_1.default.isNil(schema.maximum)) {
return;
}
if (lodash_1.default.isNil(this.maximum)) {
this.maximum = schema.maximum;
return;
}
this.maximum = Math.max(this.maximum, schema.maximum);
}
toSchema() {
if (!this.max)
return undefined;
return { maximum: this.max };
if (!lodash_1.default.isNumber(this.maximum) || this.maximum === 0) {
return {};
}
return { maximum: this.maximum };
}

@@ -27,0 +35,0 @@ }

export declare class Minimum {
keywords: Set<string>;
min: number | null;
minimum: number | null;
addObject(number: number): void;
addSchema(schema: Record<string, any>): void;
toSchema(): {
minimum?: undefined;
} | {
minimum: number;
};
}

@@ -11,16 +11,24 @@ "use strict";

this.keywords = new Set(['minimum']);
this.min = null;
this.minimum = null;
}
addObject(number) {
this.min = lodash_1.default.isNil(this.min) ? number : Math.min(this.min, number);
this.minimum = lodash_1.default.isNil(this.minimum)
? number
: Math.min(this.minimum, number);
}
addSchema(schema) {
if (schema.minimum) {
this.min = Math.min(this.min, schema.minimum);
if (lodash_1.default.isNil(schema.minimum)) {
return;
}
if (lodash_1.default.isNil(this.minimum)) {
this.minimum = schema.minimum;
return;
}
this.minimum = Math.min(this.minimum, schema.minimum);
}
toSchema() {
if (!this.min)
return undefined;
return { minimum: this.min };
if (!lodash_1.default.isNumber(this.minimum)) {
return {};
}
return { minimum: this.minimum };
}

@@ -27,0 +35,0 @@ }

@@ -7,4 +7,6 @@ export declare class MaxProperties {

toSchema(): {
maxProperties?: undefined;
} | {
maxProperties: number;
};
}

@@ -19,12 +19,15 @@ "use strict";

addSchema(schema) {
if (lodash_1.default.isNil(schema.maxProperties)) {
return;
}
if (lodash_1.default.isNil(this.maxProperties)) {
this.maxProperties = lodash_1.default.get(schema, 'maxProperties');
this.maxProperties = schema.maxProperties;
return;
}
else if (schema.maxProperties) {
this.maxProperties = Math.max(this.maxProperties, schema.maxProperties);
}
this.maxProperties = Math.max(this.maxProperties, schema.maxProperties);
}
toSchema() {
if (!this.maxProperties)
return undefined;
if (!lodash_1.default.isNumber(this.maxProperties) || this.maxProperties === 0) {
return {};
}
return { maxProperties: Math.round(this.maxProperties) };

@@ -31,0 +34,0 @@ }

@@ -7,4 +7,6 @@ export declare class MinProperties {

toSchema(): {
minProperties?: undefined;
} | {
minProperties: number;
};
}

@@ -19,12 +19,15 @@ "use strict";

addSchema(schema) {
if (lodash_1.default.isNil(schema.minProperties)) {
return;
}
if (lodash_1.default.isNil(this.minProperties)) {
this.minProperties = lodash_1.default.get(schema, 'minProperties');
this.minProperties = schema.minProperties;
return;
}
else if (schema.minProperties) {
this.minProperties = Math.min(this.minProperties, schema.minProperties);
}
this.minProperties = Math.min(this.minProperties, schema.minProperties);
}
toSchema() {
if (!this.minProperties)
return undefined;
if (!lodash_1.default.isNumber(this.minProperties)) {
return {};
}
return { minProperties: Math.round(this.minProperties) };

@@ -31,0 +34,0 @@ }

@@ -7,4 +7,6 @@ export declare class MaxLength {

toSchema(): {
maxLength?: undefined;
} | {
maxLength: number;
};
}

@@ -19,9 +19,15 @@ "use strict";

addSchema(schema) {
if (schema.maxLength) {
this.maxLength = Math.max(this.maxLength, schema.maxLength);
if (lodash_1.default.isNil(schema.maxLength)) {
return;
}
if (lodash_1.default.isNil(this.maxLength)) {
this.maxLength = schema.maxLength;
return;
}
this.maxLength = Math.max(this.maxLength, schema.maxLength);
}
toSchema() {
if (!this.maxLength)
return undefined;
if (!lodash_1.default.isNumber(this.maxLength) || this.maxLength === 0) {
return {};
}
return { maxLength: Math.round(this.maxLength) };

@@ -28,0 +34,0 @@ }

@@ -7,4 +7,6 @@ export declare class MinLength {

toSchema(): {
minLength?: undefined;
} | {
minLength: number;
};
}

@@ -19,9 +19,15 @@ "use strict";

addSchema(schema) {
if (schema.minLength) {
this.minLength = Math.min(this.minLength, schema.minLength);
if (lodash_1.default.isNil(schema.minLength)) {
return;
}
if (lodash_1.default.isNil(this.minLength)) {
this.minLength = schema.minLength;
return;
}
this.minLength = Math.min(this.minLength, schema.minLength);
}
toSchema() {
if (!this.minLength)
return undefined;
if (!lodash_1.default.isNumber(this.minLength)) {
return {};
}
return { minLength: Math.round(this.minLength) };

@@ -28,0 +34,0 @@ }

{
"name": "schematized",
"description": "Turn objects into JSON schemas! The more examples you provide, the better your schema will be.",
"version": "1.8.4",
"version": "1.8.5",
"files": [

@@ -6,0 +6,0 @@ "dist"

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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