@bedrock/validation 6.0.1 → 7.0.0

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.
@@ -8,7 +8,7 @@ jobs:
8
8
  timeout-minutes: 10
9
9
  strategy:
10
10
  matrix:
11
- node-version: [14.x]
11
+ node-version: [18.x]
12
12
  steps:
13
13
  - uses: actions/checkout@v2
14
14
  - name: Use Node.js ${{ matrix.node-version }}
@@ -24,7 +24,7 @@ jobs:
24
24
  timeout-minutes: 10
25
25
  strategy:
26
26
  matrix:
27
- node-version: [14.x]
27
+ node-version: [14.x, 16.x, 18.x]
28
28
  steps:
29
29
  - uses: actions/checkout@v2
30
30
  - name: Use Node.js ${{ matrix.node-version }}
@@ -45,7 +45,7 @@ jobs:
45
45
  timeout-minutes: 10
46
46
  strategy:
47
47
  matrix:
48
- node-version: [14.x]
48
+ node-version: [18.x]
49
49
  steps:
50
50
  - uses: actions/checkout@v2
51
51
  - name: Use Node.js ${{ matrix.node-version }}
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # bedrock-validation ChangeLog
2
2
 
3
+ ## 7.0.0 - 2022-04-28
4
+
5
+ ### Changed
6
+ - **BREAKING**: Update peer deps:
7
+ - `@bedrock/core@6`.
8
+
3
9
  ## 6.0.1 - 2022-04-01
4
10
 
5
11
  ### Fixed
package/lib/config.js CHANGED
@@ -2,8 +2,8 @@
2
2
  * Copyright (c) 2012-2022 Digital Bazaar, Inc. All rights reserved.
3
3
  */
4
4
  import {config} from '@bedrock/core';
5
- import {fileURLToPath} from 'url';
6
- import path from 'path';
5
+ import {fileURLToPath} from 'node:url';
6
+ import path from 'node:path';
7
7
 
8
8
  const __dirname = path.dirname(fileURLToPath(import.meta.url));
9
9
 
package/lib/helpers.js ADDED
@@ -0,0 +1,40 @@
1
+ /*!
2
+ * Copyright (c) 2012-2022 Digital Bazaar, Inc. All rights reserved.
3
+ */
4
+
5
+ /**
6
+ * Merges the contents of one or more objects into the first object.
7
+ *
8
+ * Arguments:
9
+ * `deep` (optional), true to do a deep-merge
10
+ * `target` the target object to merge properties into
11
+ * `objects` N objects to merge into the target.
12
+ *
13
+ * @returns {object} - The extended object.
14
+ */
15
+ export function extend() {
16
+ let deep = false;
17
+ let i = 0;
18
+ if(arguments.length > 0 && typeof arguments[0] === 'boolean') {
19
+ deep = arguments[0];
20
+ ++i;
21
+ }
22
+ const target = arguments[i] || {};
23
+ i++;
24
+ for(; i < arguments.length; ++i) {
25
+ const obj = arguments[i] || {};
26
+ Object.keys(obj).forEach(function(name) {
27
+ const value = obj[name];
28
+ if(deep && _isObject(value) && !Array.isArray(value)) {
29
+ target[name] = extend(true, target[name], value);
30
+ } else {
31
+ target[name] = value;
32
+ }
33
+ });
34
+ }
35
+ return target;
36
+ }
37
+
38
+ function _isObject(x) {
39
+ return x && typeof x === 'object';
40
+ }
package/lib/index.js CHANGED
@@ -4,9 +4,9 @@
4
4
  import * as bedrock from '@bedrock/core';
5
5
  import Ajv from 'ajv';
6
6
  import {Cache} from './Cache.js';
7
- import {promises as fs} from 'fs';
7
+ import {promises as fs} from 'node:fs';
8
8
  import {logger} from './logger.js';
9
- import PATH from 'path';
9
+ import PATH from 'node:path';
10
10
 
11
11
  const ajv = new Ajv({cache: new Cache(), serialize: false, verbose: true});
12
12
  const {util: {BedrockError}} = bedrock;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bedrock/validation",
3
- "version": "6.0.1",
3
+ "version": "7.0.0",
4
4
  "type": "module",
5
5
  "description": "Bedrock validation",
6
6
  "main": "./lib/index.js",
@@ -24,10 +24,11 @@
24
24
  },
25
25
  "homepage": "https://github.com/digitalbazaar/bedrock-validation",
26
26
  "dependencies": {
27
- "ajv": "^6.12.0"
27
+ "ajv": "^6.12.0",
28
+ "klona": "^2.0.5"
28
29
  },
29
30
  "peerDependencies": {
30
- "@bedrock/core": "^5.0.0"
31
+ "@bedrock/core": "^6.0.0"
31
32
  },
32
33
  "directories": {
33
34
  "lib": "./lib"
@@ -1,7 +1,8 @@
1
1
  /*!
2
2
  * Copyright (c) 2012-2022 Digital Bazaar, Inc. All rights reserved.
3
3
  */
4
- import * as bedrock from '@bedrock/core';
4
+ import {extend as _extend} from '../lib/helpers.js';
5
+ import {klona} from 'klona';
5
6
 
6
7
  const schema = {
7
8
  title: 'Comment',
@@ -18,7 +19,7 @@ const schema = {
18
19
 
19
20
  export default function(extend) {
20
21
  if(extend) {
21
- return bedrock.util.extend(true, bedrock.util.clone(schema), extend);
22
+ return _extend(true, klona(schema), extend);
22
23
  }
23
24
  return schema;
24
25
  }
@@ -1,9 +1,10 @@
1
1
  /*!
2
2
  * Copyright (c) 2012-2022 Digital Bazaar, Inc. All rights reserved.
3
3
  */
4
- import * as bedrock from '@bedrock/core';
4
+ import {extend as _extend} from '../lib/helpers.js';
5
5
  import identifier from './identifier.js';
6
6
  import jsonldContext from './jsonldContext.js';
7
+ import {klona} from 'klona';
7
8
  import w3cDateTime from './w3cDateTime.js';
8
9
 
9
10
  // TODO: Improve this schema
@@ -31,7 +32,7 @@ const schema = {
31
32
 
32
33
  export default function(extend) {
33
34
  if(extend) {
34
- return bedrock.util.extend(true, bedrock.util.clone(schema), extend);
35
+ return _extend(true, klona(schema), extend);
35
36
  }
36
37
  return schema;
37
38
  }
@@ -1,7 +1,8 @@
1
1
  /*!
2
2
  * Copyright (c) 2012-2022 Digital Bazaar, Inc. All rights reserved.
3
3
  */
4
- import * as bedrock from '@bedrock/core';
4
+ import {extend as _extend} from '../lib/helpers.js';
5
+ import {klona} from 'klona';
5
6
 
6
7
  const schema = {
7
8
  title: 'Description',
@@ -18,7 +19,7 @@ const schema = {
18
19
 
19
20
  export default function(extend) {
20
21
  if(extend) {
21
- return bedrock.util.extend(true, bedrock.util.clone(schema), extend);
22
+ return _extend(true, klona(schema), extend);
22
23
  }
23
24
  return schema;
24
25
  }
package/schemas/email.js CHANGED
@@ -1,7 +1,8 @@
1
1
  /*!
2
2
  * Copyright (c) 2012-2022 Digital Bazaar, Inc. All rights reserved.
3
3
  */
4
- import * as bedrock from '@bedrock/core';
4
+ import {extend as _extend} from '../lib/helpers.js';
5
+ import {klona} from 'klona';
5
6
 
6
7
  // RFC 1034 - All labels have a max length of 63 octets.
7
8
  // https://tools.ietf.org/html/rfc1034#section-3.1
@@ -28,7 +29,7 @@ export default function(extend, options) {
28
29
  }
29
30
  }
30
31
  if(extend) {
31
- return bedrock.util.extend(true, bedrock.util.clone(schema), extend);
32
+ return _extend(true, klona(schema), extend);
32
33
  }
33
34
  return schema;
34
35
  }
@@ -1,7 +1,8 @@
1
1
  /*!
2
2
  * Copyright (c) 2012-2022 Digital Bazaar, Inc. All rights reserved.
3
3
  */
4
- import * as bedrock from '@bedrock/core';
4
+ import {extend as _extend} from '../lib/helpers.js';
5
+ import {klona} from 'klona';
5
6
 
6
7
  const schema = {
7
8
  title: 'ID',
@@ -16,7 +17,7 @@ const schema = {
16
17
 
17
18
  export default function(extend) {
18
19
  if(extend) {
19
- return bedrock.util.extend(true, bedrock.util.clone(schema), extend);
20
+ return _extend(true, klona(schema), extend);
20
21
  }
21
22
  return schema;
22
23
  }
@@ -1,7 +1,8 @@
1
1
  /*!
2
2
  * Copyright (c) 2019-2022 Digital Bazaar, Inc. All rights reserved.
3
3
  */
4
- import * as bedrock from '@bedrock/core';
4
+ import {extend as _extend} from '../lib/helpers.js';
5
+ import {klona} from 'klona';
5
6
 
6
7
  const schema = {
7
8
  title: 'JSON Patch',
@@ -32,7 +33,7 @@ const schema = {
32
33
 
33
34
  export default function(extend) {
34
35
  if(extend) {
35
- return bedrock.util.extend(true, bedrock.util.clone(schema), extend);
36
+ return _extend(true, klona(schema), extend);
36
37
  }
37
38
  return schema;
38
39
  }
@@ -1,7 +1,8 @@
1
1
  /*!
2
2
  * Copyright (c) 2012-2022 Digital Bazaar, Inc. All rights reserved.
3
3
  */
4
- import * as bedrock from '@bedrock/core';
4
+ import {extend as _extend} from '../lib/helpers.js';
5
+ import {klona} from 'klona';
5
6
 
6
7
  export default function(context, extend) {
7
8
  const schema = {
@@ -48,7 +49,7 @@ export default function(context, extend) {
48
49
  }
49
50
  }
50
51
  if(extend) {
51
- return bedrock.util.extend(true, bedrock.util.clone(schema), extend);
52
+ return _extend(true, klona(schema), extend);
52
53
  }
53
54
  return schema;
54
55
  }
package/schemas/label.js CHANGED
@@ -1,7 +1,8 @@
1
1
  /*!
2
2
  * Copyright (c) 2012-2022 Digital Bazaar, Inc. All rights reserved.
3
3
  */
4
- import * as bedrock from '@bedrock/core';
4
+ import {extend as _extend} from '../lib/helpers.js';
5
+ import {klona} from 'klona';
5
6
 
6
7
  const schema = {
7
8
  title: 'Label',
@@ -19,7 +20,7 @@ const schema = {
19
20
 
20
21
  export default function(extend) {
21
22
  if(extend) {
22
- return bedrock.util.extend(true, bedrock.util.clone(schema), extend);
23
+ return _extend(true, klona(schema), extend);
23
24
  }
24
25
  return schema;
25
26
  }
@@ -1,8 +1,9 @@
1
1
  /*!
2
2
  * Copyright (c) 2012-2022 Digital Bazaar, Inc. All rights reserved.
3
3
  */
4
- import * as bedrock from '@bedrock/core';
4
+ import {extend as _extend} from '../lib/helpers.js';
5
5
  import identifier from './identifier.js';
6
+ import {klona} from 'klona';
6
7
  import w3cDateTime from './w3cDateTime.js';
7
8
 
8
9
  const signature = {
@@ -40,7 +41,7 @@ const schema = {
40
41
 
41
42
  export default function(extend) {
42
43
  if(extend) {
43
- return bedrock.util.extend(true, bedrock.util.clone(schema), extend);
44
+ return _extend(true, klona(schema), extend);
44
45
  }
45
46
  return schema;
46
47
  }
package/schemas/nonce.js CHANGED
@@ -1,7 +1,8 @@
1
1
  /*!
2
2
  * Copyright (c) 2012-2022 Digital Bazaar, Inc. All rights reserved.
3
3
  */
4
- import * as bedrock from '@bedrock/core';
4
+ import {extend as _extend} from '../lib/helpers.js';
5
+ import {klona} from 'klona';
5
6
 
6
7
  const schema = {
7
8
  title: 'Nonce',
@@ -19,7 +20,7 @@ const schema = {
19
20
 
20
21
  export default function(extend) {
21
22
  if(extend) {
22
- return bedrock.util.extend(true, bedrock.util.clone(schema), extend);
23
+ return _extend(true, klona(schema), extend);
23
24
  }
24
25
  return schema;
25
26
  }
@@ -1,7 +1,8 @@
1
1
  /*!
2
2
  * Copyright (c) 2012-2022 Digital Bazaar, Inc. All rights reserved.
3
3
  */
4
- import * as bedrock from '@bedrock/core';
4
+ import {extend as _extend} from '../lib/helpers.js';
5
+ import {klona} from 'klona';
5
6
 
6
7
  const schema = {
7
8
  title: 'Person Name',
@@ -19,7 +20,7 @@ const schema = {
19
20
 
20
21
  export default function(extend) {
21
22
  if(extend) {
22
- return bedrock.util.extend(true, bedrock.util.clone(schema), extend);
23
+ return _extend(true, klona(schema), extend);
23
24
  }
24
25
  return schema;
25
26
  }
@@ -1,7 +1,8 @@
1
1
  /*!
2
2
  * Copyright (c) 2012-2022 Digital Bazaar, Inc. All rights reserved.
3
3
  */
4
- import * as bedrock from '@bedrock/core';
4
+ import {extend as _extend} from '../lib/helpers.js';
5
+ import {klona} from 'klona';
5
6
 
6
7
  const schema = {
7
8
  title: 'Private Key PEM',
@@ -17,7 +18,7 @@ const schema = {
17
18
 
18
19
  export default function(extend) {
19
20
  if(extend) {
20
- return bedrock.util.extend(true, bedrock.util.clone(schema), extend);
21
+ return _extend(true, klona(schema), extend);
21
22
  }
22
23
  return schema;
23
24
  }
@@ -1,7 +1,8 @@
1
1
  /*!
2
2
  * Copyright (c) 2012-2022 Digital Bazaar, Inc. All rights reserved.
3
3
  */
4
- import * as bedrock from '@bedrock/core';
4
+ import {extend as _extend} from '../lib/helpers.js';
5
+ import {klona} from 'klona';
5
6
 
6
7
  const schema = {
7
8
  title: 'Public Key PEM',
@@ -17,7 +18,7 @@ const schema = {
17
18
 
18
19
  export default function(extend) {
19
20
  if(extend) {
20
- return bedrock.util.extend(true, bedrock.util.clone(schema), extend);
21
+ return _extend(true, klona(schema), extend);
21
22
  }
22
23
  return schema;
23
24
  }
@@ -1,8 +1,9 @@
1
1
  /*!
2
2
  * Copyright (c) 2019-2022 Digital Bazaar, Inc. All rights reserved.
3
3
  */
4
- import * as bedrock from '@bedrock/core';
4
+ import {extend as _extend} from '../lib/helpers.js';
5
5
  import jsonPatch from './jsonPatch.js';
6
+ import {klona} from 'klona';
6
7
 
7
8
  const schema = {
8
9
  required: ['patch', 'sequence', 'target'],
@@ -25,7 +26,7 @@ const schema = {
25
26
 
26
27
  export default function(extend) {
27
28
  if(extend) {
28
- return bedrock.util.extend(true, bedrock.util.clone(schema), extend);
29
+ return _extend(true, klona(schema), extend);
29
30
  }
30
31
  return schema;
31
32
  }
package/schemas/slug.js CHANGED
@@ -1,7 +1,8 @@
1
1
  /*!
2
2
  * Copyright (c) 2012-2022 Digital Bazaar, Inc. All rights reserved.
3
3
  */
4
- import * as bedrock from '@bedrock/core';
4
+ import {extend as _extend} from '../lib/helpers.js';
5
+ import {klona} from 'klona';
5
6
 
6
7
  const schema = {
7
8
  title: 'Slug',
@@ -21,7 +22,7 @@ const schema = {
21
22
 
22
23
  export default function(extend) {
23
24
  if(extend) {
24
- return bedrock.util.extend(true, bedrock.util.clone(schema), extend);
25
+ return _extend(true, klona(schema), extend);
25
26
  }
26
27
  return schema;
27
28
  }
package/schemas/title.js CHANGED
@@ -1,7 +1,8 @@
1
1
  /*!
2
2
  * Copyright (c) 2012-2022 Digital Bazaar, Inc. All rights reserved.
3
3
  */
4
- import * as bedrock from '@bedrock/core';
4
+ import {extend as _extend} from '../lib/helpers.js';
5
+ import {klona} from 'klona';
5
6
 
6
7
  const schema = {
7
8
  title: 'Title',
@@ -19,7 +20,7 @@ const schema = {
19
20
 
20
21
  export default function(extend) {
21
22
  if(extend) {
22
- return bedrock.util.extend(true, bedrock.util.clone(schema), extend);
23
+ return _extend(true, klona(schema), extend);
23
24
  }
24
25
  return schema;
25
26
  }
package/schemas/url.js CHANGED
@@ -1,7 +1,8 @@
1
1
  /*!
2
2
  * Copyright (c) 2012-2022 Digital Bazaar, Inc. All rights reserved.
3
3
  */
4
- import * as bedrock from '@bedrock/core';
4
+ import {extend as _extend} from '../lib/helpers.js';
5
+ import {klona} from 'klona';
5
6
 
6
7
  const schema = {
7
8
  title: 'URL',
@@ -16,7 +17,7 @@ const schema = {
16
17
 
17
18
  export default function(extend) {
18
19
  if(extend) {
19
- return bedrock.util.extend(true, bedrock.util.clone(schema), extend);
20
+ return _extend(true, klona(schema), extend);
20
21
  }
21
22
  return schema;
22
23
  }
@@ -1,7 +1,8 @@
1
1
  /*!
2
2
  * Copyright (c) 2012-2022 Digital Bazaar, Inc. All rights reserved.
3
3
  */
4
- import * as bedrock from '@bedrock/core';
4
+ import {extend as _extend} from '../lib/helpers.js';
5
+ import {klona} from 'klona';
5
6
 
6
7
  const schema = {
7
8
  title: 'W3C Date/Time',
@@ -18,7 +19,7 @@ const schema = {
18
19
 
19
20
  export default function(extend) {
20
21
  if(extend) {
21
- return bedrock.util.extend(true, bedrock.util.clone(schema), extend);
22
+ return _extend(true, klona(schema), extend);
22
23
  }
23
24
  return schema;
24
25
  }
package/test/package.json CHANGED
@@ -10,8 +10,8 @@
10
10
  "coverage-report": "c8 report"
11
11
  },
12
12
  "dependencies": {
13
- "@bedrock/core": "^5.0.0",
14
- "@bedrock/test": "^7.0.0",
13
+ "@bedrock/core": "^6.0.0",
14
+ "@bedrock/test": "^8.0.0",
15
15
  "@bedrock/validation": "file:..",
16
16
  "c8": "^7.11.0",
17
17
  "cross-env": "^7.0.3"
@@ -2,8 +2,8 @@
2
2
  * Copyright (c) 2017-2022 Digital Bazaar, Inc. All rights reserved.
3
3
  */
4
4
  import {config} from '@bedrock/core';
5
- import {fileURLToPath} from 'url';
6
- import path from 'path';
5
+ import {fileURLToPath} from 'node:url';
6
+ import path from 'node:path';
7
7
 
8
8
  const __dirname = path.dirname(fileURLToPath(import.meta.url));
9
9