@balena/sbvr-types
Advanced tools
Comparing version 4.0.0-joshbwlng-json-validation-0ee9ab14744f36249a7d7bf46ad8501d7e8c29ef-1 to 4.0.0-joshbwlng-json-validation-ae0b834536e7d295bbd2dcc75c734a901fd6d352-1
@@ -8,3 +8,3 @@ # Change Log | ||
# v4.0.0 | ||
## (2022-11-09) | ||
## (2022-11-12) | ||
@@ -11,0 +11,0 @@ * Assert that JSON input typeof is object [Josh Bowling] |
@@ -5,3 +5,2 @@ "use strict"; | ||
const TypeUtils = require("../type-utils"); | ||
const assert_1 = require("assert"); | ||
exports.types = { | ||
@@ -18,4 +17,6 @@ postgres: 'TEXT', | ||
exports.validate = TypeUtils.validate.checkRequired((value) => { | ||
if (typeof value !== 'object') { | ||
throw new Error(`is not an object/array: ${typeof value}`); | ||
} | ||
try { | ||
(0, assert_1.strict)(typeof value === 'object'); | ||
return JSON.stringify(value); | ||
@@ -22,0 +23,0 @@ } |
{ | ||
"name": "@balena/sbvr-types", | ||
"version": "4.0.0-joshbwlng-json-validation-0ee9ab14744f36249a7d7bf46ad8501d7e8c29ef-1", | ||
"version": "4.0.0-joshbwlng-json-validation-ae0b834536e7d295bbd2dcc75c734a901fd6d352-1", | ||
"description": "SBVR type definitions.", | ||
@@ -34,3 +34,2 @@ "main": "out", | ||
"@types/mocha": "^9.1.0", | ||
"@types/node": "^18.11.9", | ||
"bluebird": "^3.7.2", | ||
@@ -68,4 +67,4 @@ "chai": "^4.3.6", | ||
"versionist": { | ||
"publishedAt": "2022-11-09T10:48:26.013Z" | ||
"publishedAt": "2022-11-12T12:31:12.948Z" | ||
} | ||
} |
import * as TypeUtils from '../type-utils'; | ||
import { strict as assert } from 'assert'; | ||
export const types = { | ||
@@ -17,6 +15,8 @@ postgres: 'TEXT', | ||
export const validate = TypeUtils.validate.checkRequired((value) => { | ||
// Disallow primitives | ||
if (typeof value !== 'object') { | ||
throw new Error(`is not an object/array: ${typeof value}`); | ||
} | ||
try { | ||
// Disallow primitives | ||
assert(typeof value === 'object'); | ||
return JSON.stringify(value); | ||
@@ -23,0 +23,0 @@ } catch { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
104330
17
1644