Skip to content

Commit

Permalink
22-10215 schema added for 'Institution details' page
Browse files Browse the repository at this point in the history
  • Loading branch information
mghisilieri committed Dec 2, 2024
1 parent 1cc39d1 commit 42fdbc3
Show file tree
Hide file tree
Showing 4 changed files with 116 additions and 1 deletion.
37 changes: 37 additions & 0 deletions dist/22-10215-schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "22-10215 Statement of Assurance of Compliance with 95 Percent Enrollment Ratios (22-10215)",
"type": "object",
"additionalProperties": false,
"definitions": {
"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"
}
},
"properties": {
"institutionDetails": {
"type": "object",
"required": [
"institutionName",
"facilityCode",
"termStartDate",
"dateOfCalculations"
],
"properties": {
"institutionName": {
"type": "string"
},
"facilityCode": {
"type": "string"
},
"termStartDate": {
"$ref": "#/definitions/date"
},
"dateOfCalculations": {
"$ref": "#/definitions/date"
}
}
}
}
}
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.5.7",
"version": "24.6.0",
"license": "CC0-1.0",
"repository": {
"type": "git",
Expand Down
36 changes: 36 additions & 0 deletions src/schemas/22-10215/schema.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import _ from 'lodash';
import definitions from '../../common/definitions';

const origDefinitions = _.cloneDeep(definitions);

const pickedDefinitions = _.pick(origDefinitions, ['date']);

const schema = {
$schema: 'http://json-schema.org/draft-04/schema#',
title: '22-10215 Statement of Assurance of Compliance with 95 Percent Enrollment Ratios (22-10215)',
type: 'object',
additionalProperties: false,
definitions: pickedDefinitions,
properties: {
institutionDetails: {
type: 'object',
required: ['institutionName', 'facilityCode', 'termStartDate', 'dateOfCalculations'],
properties: {
institutionName: {
type: 'string',
},
facilityCode: {
type: 'string',
},
termStartDate: {
$ref: '#/definitions/date',
},
dateOfCalculations: {
$ref: '#/definitions/date',
},
},
},
},
};

export default schema;
42 changes: 42 additions & 0 deletions test/schemas/22-10215/schema.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { expect } from 'chai';
import { it } from 'mocha';
import { cloneDeep } from 'lodash';
import schema from '../../../src/schemas/22-10215/schema';
import SchemaTestHelper from '../../support/schema-test-helper';

const schemaWithoutRequired = cloneDeep(schema);
delete schemaWithoutRequired.required;

const schemaTestHelper = new SchemaTestHelper(schemaWithoutRequired);

const testData = {
institutionDetails: {
institutionName: {
valid: 'Institution of Test',
invalid: null,
},
facilityCode: {
valid: 'IoT 123',
invalid: 123456,
},
termStartDate: {
valid: '2024-11-25',
invalid: 'start date',
},
dateOfCalculations: {
valid: '2024-11-28',
invalid: 20241128,
},
},
};

describe('22-10215 Schema', () => {
it('should have required fields', () => {
expect(schema.required).to.deep.equal('institutionName', 'facilityCode', 'termStartDate', 'dateOfCalculations');
});

schemaTestHelper.testValidAndInvalid('institutionName', testData.institutionName);
schemaTestHelper.testValidAndInvalid('facilityCode', testData.facilityCode);
schemaTestHelper.testValidAndInvalid('termStartDate', testData.termStartDate);
schemaTestHelper.testValidAndInvalid('dateOfCalculations', testData.dateOfCalculations);
});

0 comments on commit 42fdbc3

Please sign in to comment.