Skip to content

Commit

Permalink
Toxic Exposure: add BE validation for invalid year (#939)
Browse files Browse the repository at this point in the history
* dbex/93403-validate-dates: first draft of date validation

* dbex/93403-validate-dates: fix failing tests

* dbex/93403-validate-dates:
- allow XX for month and day (not year)
- expand to all TE elements

* dbex/93403-validate-dates: add tests for minimumYearDateRange

* dbex/93403-validate-dates: add comment

* dbex/93403-validate-dates: add more tests for minimumYearDateRange

* dbex/93403-validate-dates: add more tests for gulfWar1990Details

* dbex/93403-validate-dates: add remove nullableMinimumYearDate, not needed

* dbex/93403-validate-dates: add add gulfWar2001Details tests, remove debugging garbage

* dbex/93403-validate-dates: add add remaining TE tests

* dbex/93403-validate-dates: add update package.json (again)

* dbex/93403-validate-dates: add unit test tweak
  • Loading branch information
sethdarragile6 authored Oct 3, 2024
1 parent a2088d2 commit be610f6
Show file tree
Hide file tree
Showing 9 changed files with 473 additions and 1 deletion.
154 changes: 154 additions & 0 deletions dist/21-526EZ-ALLCLAIMS-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,21 @@
"to"
]
},
"minimumYearDateRange": {
"type": "object",
"properties": {
"startDate": {
"$ref": "#/definitions/minimumYearDate"
},
"endDate": {
"$ref": "#/definitions/minimumYearDate"
}
}
},
"minimumYearDate": {
"pattern": "^(?:19|20)[0-9][0-9]-(0[1-9]|1[0-2]|XX)-(0[1-9]|[1-2][0-9]|3[0-1]|XX)$",
"type": "string"
},
"ratedDisabilities": {
"type": "array",
"maxItems": 100,
Expand Down Expand Up @@ -771,6 +786,145 @@
}
}
},
"toxicExposure": {
"type": "object",
"properties": {
"gulfWar1990Details": {
"type": "object",
"properties": {
"afghanistan": {
"$ref": "#/definitions/minimumYearDateRange"
},
"bahrain": {
"$ref": "#/definitions/minimumYearDateRange"
},
"egypt": {
"$ref": "#/definitions/minimumYearDateRange"
},
"iraq": {
"$ref": "#/definitions/minimumYearDateRange"
},
"israel": {
"$ref": "#/definitions/minimumYearDateRange"
},
"jordan": {
"$ref": "#/definitions/minimumYearDateRange"
},
"kuwait": {
"$ref": "#/definitions/minimumYearDateRange"
},
"neutralzone": {
"$ref": "#/definitions/minimumYearDateRange"
},
"oman": {
"$ref": "#/definitions/minimumYearDateRange"
},
"qatar": {
"$ref": "#/definitions/minimumYearDateRange"
},
"saudiarabia": {
"$ref": "#/definitions/minimumYearDateRange"
},
"somalia": {
"$ref": "#/definitions/minimumYearDateRange"
},
"syria": {
"$ref": "#/definitions/minimumYearDateRange"
},
"uae": {
"$ref": "#/definitions/minimumYearDateRange"
},
"turkey": {
"$ref": "#/definitions/minimumYearDateRange"
},
"waters": {
"$ref": "#/definitions/minimumYearDateRange"
},
"airspace": {
"$ref": "#/definitions/minimumYearDateRange"
}
}
},
"gulfWar2001Details": {
"type": "object",
"properties": {
"djibouti": {
"$ref": "#/definitions/minimumYearDateRange"
},
"lebanon": {
"$ref": "#/definitions/minimumYearDateRange"
},
"uzbekistan": {
"$ref": "#/definitions/minimumYearDateRange"
},
"yemen": {
"$ref": "#/definitions/minimumYearDateRange"
},
"airspace": {
"$ref": "#/definitions/minimumYearDateRange"
}
}
},
"herbicideDetails": {
"type": "object",
"properties": {
"cambodia": {
"$ref": "#/definitions/minimumYearDateRange"
},
"guam": {
"$ref": "#/definitions/minimumYearDateRange"
},
"koreandemilitarizedzone": {
"$ref": "#/definitions/minimumYearDateRange"
},
"johnston": {
"$ref": "#/definitions/minimumYearDateRange"
},
"laos": {
"$ref": "#/definitions/minimumYearDateRange"
},
"c123": {
"$ref": "#/definitions/minimumYearDateRange"
},
"thailand": {
"$ref": "#/definitions/minimumYearDateRange"
},
"vietnam": {
"$ref": "#/definitions/minimumYearDateRange"
}
}
},
"otherExposuresDetails": {
"type": "object",
"properties": {
"asbestos": {
"$ref": "#/definitions/minimumYearDateRange"
},
"chemical": {
"$ref": "#/definitions/minimumYearDateRange"
},
"mos": {
"$ref": "#/definitions/minimumYearDateRange"
},
"mustardgas": {
"$ref": "#/definitions/minimumYearDateRange"
},
"radiation": {
"$ref": "#/definitions/minimumYearDateRange"
},
"water": {
"$ref": "#/definitions/minimumYearDateRange"
}
}
},
"otherHerbicideLocations": {
"$ref": "#/definitions/minimumYearDateRange"
},
"specifyOtherExposures": {
"$ref": "#/definitions/minimumYearDateRange"
}
}
},
"serviceInformation": {
"type": "object",
"required": [
Expand Down
15 changes: 15 additions & 0 deletions dist/definitions.json
Original file line number Diff line number Diff line change
Expand Up @@ -1039,6 +1039,21 @@
"null"
]
},
"minimumYearDate": {
"pattern": "^(?:19|20)[0-9][0-9]-(0[1-9]|1[0-2]|XX)-(0[1-9]|[1-2][0-9]|3[0-1]|XX)$",
"type": "string"
},
"minimumYearDateRange": {
"type": "object",
"properties": {
"startDate": {
"$ref": "#/definitions/minimumYearDate"
},
"endDate": {
"$ref": "#/definitions/minimumYearDate"
}
}
},
"requiredDate": {
"type": "string",
"pattern": "^\\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vets-json-schema",
"version": "24.3.3",
"version": "24.4.0",
"license": "CC0-1.0",
"repository": {
"type": "git",
Expand Down
24 changes: 24 additions & 0 deletions src/common/definitions.js
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,18 @@ const dateRange = {
},
};

const minimumYearDateRange = {
type: 'object',
properties: {
startDate: {
$ref: '#/definitions/minimumYearDate',
},
endDate: {
$ref: '#/definitions/minimumYearDate',
},
},
};

const date = {
pattern: '^(\\d{4}|XXXX)-(0[1-9]|1[0-2]|XX)-(0[1-9]|[1-2][0-9]|3[0-1]|XX)$',
type: 'string',
Expand All @@ -494,6 +506,16 @@ const nullableDate = {
type: ['string', 'null'],
};

// currently being used primarily by the 526EZ app for toxic exposure dates,
// which technically require either just YYYY or YYYY-MM. Partial dates are not
// yet supported in the FE, but dates with X's still occasionally get through.
// Since the BE knows how to parse XX for the month and day, the below regex
// still allows XX for them- however, the year MUST be valid and with no X's
const minimumYearDate = {
pattern: '^(?:19|20)[0-9][0-9]-(0[1-9]|1[0-2]|XX)-(0[1-9]|[1-2][0-9]|3[0-1]|XX)$',
type: 'string',
};

// XXXX-XX-XX not allowed
const requiredDate = {
type: 'string',
Expand Down Expand Up @@ -987,6 +1009,8 @@ export default {
dateRange,
date,
nullableDate,
minimumYearDate,
minimumYearDateRange,
requiredDate,
rejectOnlyWhitespace,
dischargeType,
Expand Down
141 changes: 141 additions & 0 deletions src/schemas/21-526EZ-allclaims/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ const schema = {
vaTreatmentCenterAddress: vaTreatmentCenterAddressDef,
dateRange: definitions.dateRange,
dateRangeAllRequired: _.set('required', ['from', 'to'], definitions.dateRange),
minimumYearDateRange: definitions.minimumYearDateRange,
minimumYearDate: definitions.minimumYearDate,
ratedDisabilities: _.merge(disabilitiesBaseDef, {
minItems: 1,
items: {
Expand Down Expand Up @@ -275,6 +277,145 @@ const schema = {
},
},
},
toxicExposure: {
type: 'object',
properties: {
gulfWar1990Details: {
type: 'object',
properties: {
afghanistan: {
$ref: '#/definitions/minimumYearDateRange'
},
bahrain: {
$ref: '#/definitions/minimumYearDateRange'
},
egypt: {
$ref: '#/definitions/minimumYearDateRange'
},
iraq: {
$ref: '#/definitions/minimumYearDateRange'
},
israel: {
$ref: '#/definitions/minimumYearDateRange'
},
jordan: {
$ref: '#/definitions/minimumYearDateRange'
},
kuwait: {
$ref: '#/definitions/minimumYearDateRange'
},
neutralzone: {
$ref: '#/definitions/minimumYearDateRange'
},
oman: {
$ref: '#/definitions/minimumYearDateRange'
},
qatar: {
$ref: '#/definitions/minimumYearDateRange'
},
saudiarabia: {
$ref: '#/definitions/minimumYearDateRange'
},
somalia: {
$ref: '#/definitions/minimumYearDateRange'
},
syria: {
$ref: '#/definitions/minimumYearDateRange'
},
uae: {
$ref: '#/definitions/minimumYearDateRange'
},
turkey: {
$ref: '#/definitions/minimumYearDateRange'
},
waters: {
$ref: '#/definitions/minimumYearDateRange'
},
airspace: {
$ref: '#/definitions/minimumYearDateRange'
}
}
},
gulfWar2001Details: {
type: 'object',
properties: {
djibouti: {
$ref: '#/definitions/minimumYearDateRange'
},
lebanon: {
$ref: '#/definitions/minimumYearDateRange'
},
uzbekistan: {
$ref: '#/definitions/minimumYearDateRange'
},
yemen: {
$ref: '#/definitions/minimumYearDateRange'
},
airspace: {
$ref: '#/definitions/minimumYearDateRange'
}
}
},
herbicideDetails: {
type: 'object',
properties: {
cambodia: {
$ref: '#/definitions/minimumYearDateRange'
},
guam: {
$ref: '#/definitions/minimumYearDateRange'
},
koreandemilitarizedzone: {
$ref: '#/definitions/minimumYearDateRange'
},
johnston: {
$ref: '#/definitions/minimumYearDateRange'
},
laos: {
$ref: '#/definitions/minimumYearDateRange'
},
c123: {
$ref: '#/definitions/minimumYearDateRange'
},
thailand: {
$ref: '#/definitions/minimumYearDateRange'
},
vietnam: {
$ref: '#/definitions/minimumYearDateRange'
}
}
},
otherExposuresDetails: {
type: 'object',
properties: {
asbestos: {
$ref: '#/definitions/minimumYearDateRange'
},
chemical: {
$ref: '#/definitions/minimumYearDateRange'
},
mos: {
$ref: '#/definitions/minimumYearDateRange'
},
mustardgas: {
$ref: '#/definitions/minimumYearDateRange'
},
radiation: {
$ref: '#/definitions/minimumYearDateRange'
},
water: {
$ref: '#/definitions/minimumYearDateRange'
}
}
},
otherHerbicideLocations: {
$ref: '#/definitions/minimumYearDateRange'
},
specifyOtherExposures: {
$ref: '#/definitions/minimumYearDateRange'
}
}
},
serviceInformation: {
type: 'object',
required: ['servicePeriods'],
Expand Down
Loading

0 comments on commit be610f6

Please sign in to comment.