@kravc/schema 2.2.3 → 2.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kravc/schema",
3
- "version": "2.2.3",
3
+ "version": "2.3.1",
4
4
  "description": "Advanced JSON schema manipulation and validation library.",
5
5
  "keywords": [
6
6
  "JSON",
@@ -34,15 +34,15 @@
34
34
  "lodash.pick": "^4.4.0",
35
35
  "lodash.uniq": "^4.5.0",
36
36
  "security-context": "^4.0.0",
37
- "validator": "^12.2.0",
38
- "z-schema": "^5.0.0"
37
+ "validator": "^13.7.0",
38
+ "z-schema": "^5.0.2"
39
39
  },
40
40
  "devDependencies": {
41
- "chai": "^4.2.0",
42
- "eslint": "^7.12.1",
43
- "js-yaml": "^3.13.1",
44
- "jsonld": "^5.0.0",
45
- "mocha": "^8.2.1",
41
+ "chai": "^4.3.4",
42
+ "eslint": "^8.6.0",
43
+ "js-yaml": "^4.1.0",
44
+ "jsonld": "^5.2.0",
45
+ "mocha": "^9.1.3",
46
46
  "nyc": "^15.0.1"
47
47
  },
48
48
  "nyc": {
@@ -1,13 +1,13 @@
1
1
  'use strict'
2
2
 
3
+ const { load } = require('js-yaml')
3
4
  const { Schema } = require('src')
4
5
  const { expect } = require('chai')
5
- const { safeLoad } = require('js-yaml')
6
6
  const { readFileSync } = require('fs')
7
7
 
8
8
  const loadSync = (yamlPath) => {
9
9
  const id = yamlPath.split('.')[0].split('/').reverse()[0]
10
- const source = safeLoad(readFileSync(yamlPath))
10
+ const source = load(readFileSync(yamlPath))
11
11
 
12
12
  return new Schema(source, id)
13
13
  }
@@ -1,13 +1,13 @@
1
1
  'use strict'
2
2
 
3
+ const { load } = require('js-yaml')
3
4
  const { expect } = require('chai')
4
- const { safeLoad } = require('js-yaml')
5
5
  const { readFileSync } = require('fs')
6
6
  const { Schema, Validator } = require('src')
7
7
 
8
8
  const loadSync = (yamlPath) => {
9
9
  const id = yamlPath.split('.')[0].split('/').reverse()[0]
10
- const source = safeLoad(readFileSync(yamlPath))
10
+ const source = load(readFileSync(yamlPath))
11
11
 
12
12
  return new Schema(source, id)
13
13
  }
@@ -11,17 +11,19 @@ const normalizeType = (type, value) => {
11
11
  }
12
12
 
13
13
  if (isBoolean) {
14
- const isBoolean = typeof value === 'boolean'
15
- const isNumber = typeof value === 'number'
14
+ const isNumberValue = typeof value === 'number'
15
+ const isStringValue = typeof value === 'string'
16
16
 
17
- if (!isBoolean) {
18
- if (isNumber) {
17
+ const shouldConvertValue = isNumberValue || isStringValue
18
+
19
+ if (shouldConvertValue) {
20
+ if (isNumberValue) {
19
21
  normalizedValue = Boolean(value)
22
+ }
20
23
 
21
- } else {
24
+ if (isStringValue) {
22
25
  const isTrue = value.toLowerCase() === 'true' || value === '1'
23
26
  normalizedValue = isTrue ? true : false
24
-
25
27
  }
26
28
  }
27
29
  }