@jsonresume/schema 1.0.1 → 1.1.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.
- package/README.md +4 -2
- package/package.json +2 -2
- package/schema.json +5 -6
- package/validator.js +11 -11
package/README.md
CHANGED
|
@@ -15,16 +15,18 @@ The current working version of the schema is `v1.0.0` that is represented by the
|
|
|
15
15
|
|
|
16
16
|
All PR's for the next version should be made against the `develop` branch.
|
|
17
17
|
|
|
18
|
+
This enforces that the schema package, always has the official stable release of the schema.
|
|
19
|
+
|
|
18
20
|
### Getting started
|
|
19
21
|
|
|
20
22
|
```
|
|
21
|
-
npm install --save
|
|
23
|
+
npm install --save @jsonresume/schema
|
|
22
24
|
```
|
|
23
25
|
|
|
24
26
|
To use
|
|
25
27
|
|
|
26
28
|
```js
|
|
27
|
-
const resumeSchema = require("
|
|
29
|
+
const resumeSchema = require("@jsonresume/schema");
|
|
28
30
|
resumeSchema.validate(
|
|
29
31
|
{ name: "Thomas" },
|
|
30
32
|
function (err, report) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsonresume/schema",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "JSON Resume Schema",
|
|
5
5
|
"private": false,
|
|
6
6
|
"main": "validator.js",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"validator.js"
|
|
28
28
|
],
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"
|
|
30
|
+
"jsonschema": "^1.4.1"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"ajv-cli": "^3.3.0",
|
package/schema.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
|
-
"$schema": "http://json-schema.org/draft-
|
|
3
|
-
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
" $id": "http://example.com/example.json",
|
|
4
|
+
"additionalProperties": true,
|
|
4
5
|
"definitions": {
|
|
5
6
|
"iso8601": {
|
|
6
7
|
"type": "string",
|
|
7
|
-
"description": "e.g. 2014-06-29",
|
|
8
|
+
"description": "Similar to the standard date type, but each section after the year is optional. e.g. 2014-06-29 or 2023-04",
|
|
8
9
|
"pattern": "^([1-2][0-9]{3}-[0-1][0-9]-[0-3][0-9]|[1-2][0-9]{3}-[0-1][0-9]|[1-2][0-9]{3})$"
|
|
9
10
|
}
|
|
10
11
|
},
|
|
@@ -274,9 +275,7 @@
|
|
|
274
275
|
"description": "e.g. Certified Kubernetes Administrator"
|
|
275
276
|
},
|
|
276
277
|
"date": {
|
|
277
|
-
"
|
|
278
|
-
"description": "e.g. 1989-06-12",
|
|
279
|
-
"format": "date"
|
|
278
|
+
"$ref": "#/definitions/iso8601"
|
|
280
279
|
},
|
|
281
280
|
"url": {
|
|
282
281
|
"type": "string",
|
package/validator.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
var
|
|
3
|
-
var
|
|
1
|
+
"use strict";
|
|
2
|
+
var schema = require("./schema");
|
|
3
|
+
var Validator = require("jsonschema").Validator;
|
|
4
4
|
|
|
5
5
|
function validate(resumeJson, callback) {
|
|
6
|
-
var
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
var v = new Validator();
|
|
7
|
+
|
|
8
|
+
const validation = v.validate(resumeJson, schema);
|
|
9
|
+
|
|
10
|
+
if (!validation.valid) {
|
|
11
|
+
return callback(validation.errors, false);
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
return callback(null, true);
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
module.exports = {
|
|
18
18
|
validate: validate,
|
|
19
|
-
schema: schema
|
|
19
|
+
schema: schema,
|
|
20
20
|
};
|