Skip to content

Commit

Permalink
Merge pull request #348 from jsonresume/better-dates
Browse files Browse the repository at this point in the history
Better dates
  • Loading branch information
evanplaice authored Apr 23, 2020
2 parents d44449f + ec23850 commit 4e25012
Show file tree
Hide file tree
Showing 15 changed files with 370 additions and 58 deletions.
66 changes: 17 additions & 49 deletions schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@
"title": "Resume Schema",
"type": "object",
"additionalProperties": false,
"definitions": {
"iso8601": {
"type": "string",
"description": "e.g. 2014-06-29",
"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})$"
}
},
"properties": {
"basics": {
"type": "object",
Expand Down Expand Up @@ -115,16 +122,8 @@
"description": "e.g. http://facebook.example.com",
"format": "uri"
},
"startDate": {
"type": "string",
"description": "resume.json uses the ISO 8601 date standard e.g. 2014-06-29",
"format": "date"
},
"endDate": {
"type": "string",
"description": "e.g. 2012-06-29",
"format": "date"
},
"startDate": { "$ref": "#/definitions/iso8601" },
"endDate": { "$ref": "#/definitions/iso8601" },
"summary": {
"type": "string",
"description": "Give an overview of your responsibilities at the company"
Expand Down Expand Up @@ -161,16 +160,8 @@
"description": "e.g. http://facebook.example.com",
"format": "uri"
},
"startDate": {
"type": "string",
"description": "resume.json uses the ISO 8601 date standard e.g. 2014-06-29",
"format": "date"
},
"endDate": {
"type": "string",
"description": "e.g. 2012-06-29",
"format": "date"
},
"startDate": { "$ref": "#/definitions/iso8601" },
"endDate": { "$ref": "#/definitions/iso8601" },
"summary": {
"type": "string",
"description": "Give an overview of your responsibilities at the company"
Expand Down Expand Up @@ -206,16 +197,8 @@
"type": "string",
"description": "e.g. Bachelor"
},
"startDate": {
"type": "string",
"description": "e.g. 2014-06-29",
"format": "date"
},
"endDate": {
"type": "string",
"description": "e.g. 2012-06-29",
"format": "date"
},
"startDate": { "$ref": "#/definitions/iso8601" },
"endDate": { "$ref": "#/definitions/iso8601" },
"gpa": {
"type": "string",
"description": "grade point average, e.g. 3.67/4.0"
Expand Down Expand Up @@ -244,11 +227,7 @@
"type": "string",
"description": "e.g. One of the 100 greatest minds of the century"
},
"date": {
"type": "string",
"description": "e.g. 1989-06-12",
"format": "date"
},
"date": { "$ref": "#/definitions/iso8601" },
"awarder": {
"type": "string",
"description": "e.g. Time Magazine"
Expand Down Expand Up @@ -276,10 +255,7 @@
"type": "string",
"description": "e.g. IEEE, Computer Magazine"
},
"releaseDate": {
"type": "string",
"description": "e.g. 1990-08-01"
},
"releaseDate": { "$ref": "#/definitions/iso8601" },
"url": {
"type": "string",
"description": "e.g. http://www.computer.org.example.com/csdl/mags/co/1996/10/rx069-abs.html",
Expand Down Expand Up @@ -414,16 +390,8 @@
"description": "e.g. AngularJS"
}
},
"startDate": {
"type": "string",
"description": "resume.json uses the ISO 8601 date standard e.g. 2014-06-29",
"format": "date"
},
"endDate": {
"type": "string",
"description": "e.g. 2012-06-29",
"format": "date"
},
"startDate": { "$ref": "#/definitions/iso8601" },
"endDate": { "$ref": "#/definitions/iso8601" },
"url": {
"type": "string",
"format":"uri",
Expand Down
14 changes: 14 additions & 0 deletions test/__test__/awards.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,20 @@
}
]
},
"dateValid2": {
"awards": [
{
"date": "2014-11"
}
]
},
"dateValid3": {
"awards": [
{
"date": "2014"
}
]
},
"dateInvalid": {
"awards": [
{
Expand Down
6 changes: 6 additions & 0 deletions test/__test__/dates.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"yearMonthDay": "2013-12-02",
"yearMonth": "2013-12-01",
"year": "2013-12-01",
"invalid": "2013-12-021"
}
28 changes: 28 additions & 0 deletions test/__test__/education.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,20 @@
}
]
},
"startDateValid2": {
"education": [
{
"startDate": "2011-06"
}
]
},
"startDateValid3": {
"education": [
{
"startDate": "2011"
}
]
},
"startDateInvalid": {
"education": [
{
Expand All @@ -68,6 +82,20 @@
}
]
},
"endDateValid2": {
"education": [
{
"endDate": "2014-01"
}
]
},
"endDateValid3": {
"education": [
{
"endDate": "2014"
}
]
},
"endDateInvalid": {
"education": [
{
Expand Down
28 changes: 28 additions & 0 deletions test/__test__/projects.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,20 @@
}
]
},
"startDateValid2": {
"projects": [
{
"startDate": "2015-08"
}
]
},
"startDateValid3": {
"projects": [
{
"startDate": "2015"
}
]
},
"startDateInvalid": {
"projects": [
{
Expand All @@ -118,6 +132,20 @@
}
]
},
"endDateValid2": {
"projects": [
{
"endDate": "2016-08"
}
]
},
"endDateValid3": {
"projects": [
{
"endDate": "2016"
}
]
},
"endDateInvalid": {
"projects": [
{
Expand Down
14 changes: 14 additions & 0 deletions test/__test__/publications.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,20 @@
}
]
},
"releaseDateValid2": {
"publications": [
{
"releaseDate": "2014-10"
}
]
},
"releaseDateValid3": {
"publications": [
{
"releaseDate": "2014"
}
]
},
"releaseDateInvalid": {
"publications": [
{
Expand Down
28 changes: 28 additions & 0 deletions test/__test__/volunteer.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,20 @@
}
]
},
"startDateValid2": {
"volunteer": [
{
"startDate": "2012-01"
}
]
},
"startDateValid3": {
"volunteer": [
{
"startDate": "2012"
}
]
},
"startDateInvalid": {
"volunteer": [
{
Expand All @@ -68,6 +82,20 @@
}
]
},
"endDateValid2": {
"volunteer": [
{
"endDate": "2013-01"
}
]
},
"endDateValid3": {
"volunteer": [
{
"endDate": "2013"
}
]
},
"endDateInvalid": {
"volunteer": [
{
Expand Down
28 changes: 28 additions & 0 deletions test/__test__/work.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,20 @@
}
]
},
"startDateValid2": {
"work": [
{
"startDate": "2013-12"
}
]
},
"startDateValid3": {
"work": [
{
"startDate": "2013"
}
]
},
"startDateInvalid": {
"work": [
{
Expand All @@ -96,6 +110,20 @@
}
]
},
"endDateValid2": {
"work": [
{
"endDate": "2014-12"
}
]
},
"endDateValid3": {
"work": [
{
"endDate": "2014"
}
]
},
"endDateInvalid": {
"work": [
{
Expand Down
18 changes: 17 additions & 1 deletion test/awards.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,30 @@ test('awards[].title - invalid', (t) => {
t.end();
});

test('awards[].date - valid', (t) => {
test('awards[].date - valid [YYYY-MM-DD]', (t) => {
validate(fixtures.dateValid, (err, valid) => {
t.equal(err, null, 'err should be null');
t.true(valid, 'valid is true');
});
t.end();
});

test('awards[].date - valid [YYYY-MM]', (t) => {
validate(fixtures.dateValid2, (err, valid) => {
t.equal(err, null, 'err should be null');
t.true(valid, 'valid is true');
});
t.end();
});

test('awards[].date - valid [YYYY]', (t) => {
validate(fixtures.dateValid3, (err, valid) => {
t.equal(err, null, 'err should be null');
t.true(valid, 'valid is true');
});
t.end();
});

test('awards[].date - invalid', (t) => {
validate(fixtures.dateInvalid, (err, valid) => {
t.notEqual(err, null, 'err should contain an error');
Expand Down
Loading

0 comments on commit 4e25012

Please sign in to comment.