Skip to content

Commit

Permalink
fix: add null and undefined values to optional fields in json schemas
Browse files Browse the repository at this point in the history
  • Loading branch information
Sepehr-Sobhani committed Jul 20, 2023
1 parent 921267c commit e84c8a1
Show file tree
Hide file tree
Showing 10 changed files with 100 additions and 63 deletions.
12 changes: 8 additions & 4 deletions app/data/jsonSchemaForm/contactSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,24 @@ const contactSchema = {
"^(\\+?\\d{1,2}[\\s,-]?)?\\(?\\d{3}\\)?[\\s.-]?\\d{3}[\\s.-]?\\d{4}$",
},
phoneExt: {
type: "string",
type: [null, "string"],
title: "Phone Extension",
default: undefined,
},
companyName: {
type: "string",
type: [null, "string"],
title: "Company Name",
default: undefined,
},
contactPosition: {
type: "string",
type: [null, "string"],
title: "Position",
default: undefined,
},
comments: {
type: "string",
type: [null, "string"],
title: "Comments",
default: undefined,
},
},
};
Expand Down
25 changes: 16 additions & 9 deletions app/data/jsonSchemaForm/projectSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,15 @@ const projectSchema = {
default: undefined,
},
summary: { type: "string", title: "Project Description" },
projectType: { type: "string", title: "Project Type" },
projectType: {
type: [null, "string"],
title: "Project Type",
default: undefined,
},
score: {
type: "number",
type: [null, "number"],
title: "Score",
},
rank: {
type: "number",
title: "Rank",
default: undefined,
},
operatorId: {
type: "number",
Expand All @@ -56,14 +57,20 @@ const projectSchema = {
anyOf: undefined,
},
additionalSectorInformation: {
type: "string",
type: [null, "string"],
title: "Additional Sector Information",
default: undefined,
},
contractNumber: {
type: "string",
type: [null, "string"],
title: "Contract Number",
default: undefined,
},
comments: {
type: [null, "string"],
title: "General Comments",
default: undefined,
},
comments: { type: "string", title: "General Comments" },
},
};

Expand Down
28 changes: 17 additions & 11 deletions schema/data/prod/json_schema/contact.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"schema": {
"$schema": "http://json-schema.org/draft-07/schema",
"type": "object",
"required": ["givenName", "familyName", "email", "phone"],
"required": ["givenName", "familyName", "email"],
"properties": {
"givenName": {
"type": "string",
Expand All @@ -14,27 +14,33 @@
},
"email": {
"type": "string",
"title": "Email"
"title": "Email",
"pattern": "^[\\.\\w-]+@([\\w-]+\\.)+[\\w-]{2,4}$"
},
"phone": {
"type": "string",
"title": "Phone"
"title": "Phone",
"pattern": "^(\\+?\\d{1,2}[\\s,-]?)?\\(?\\d{3}\\)?[\\s.-]?\\d{3}[\\s.-]?\\d{4}$"
},
"phoneExt": {
"type": "string",
"title": "Phone Extension"
"type": ["null", "string"],
"title": "Phone Extension",
"default": "undefined"
},
"companyName": {
"type": "string",
"title": "Company Name"
"type": ["null", "string"],
"title": "Company Name",
"default": "undefined"
},
"contactPosition": {
"type": "string",
"title": "Position"
"type": ["null", "string"],
"title": "Position",
"default": "undefined"
},
"comments": {
"type": "string",
"title": "Comments"
"type": ["null", "string"],
"title": "Comments",
"default": "undefined"
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions schema/data/prod/json_schema/emission_intensity_report.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"comments": {
"type": ["null", "string"],
"title": "General Comments",
"default": "null"
"default": null
},
"measurementPeriodStartDate": {
"title": "TEIMP Start Date",
Expand All @@ -40,7 +40,7 @@
"productionFunctionalUnit": {
"title": "Production Functional Unit",
"type": ["null", "string"],
"default": "null"
"default": null
},
"baselineEmissionIntensity": {
"title": "Baseline Emission Intensity (BEI)",
Expand Down
32 changes: 19 additions & 13 deletions schema/data/prod/json_schema/milestone.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,21 @@
"title": "Report Due Date"
},
"submittedDate": {
"type": "string",
"title": "Report Received Date"
"type": ["null", "string"],
"title": "Report Received Date",
"default": "undefined"
},
"substantialCompletionDate": {
"type": "string",
"title": "Substantial Completion Date"
},
"certifiedBy": {
"type": "string",
"title": "Certifier"
"type": ["null", "string"],
"title": "Certifier",
"default": "undefined"
},
"certifierProfessionalDesignation": {
"type": "string",
"type": ["null", "string"],
"title": "Professional Designation",
"default": "Professional Engineer",
"anyOf": [
Expand Down Expand Up @@ -80,20 +82,23 @@
"title": "Maximum Amount This Milestone"
},
"adjustedGrossAmount": {
"type": "number",
"title": "Gross Payment Amount This Milestone"
"type": ["null", "number"],
"title": "Gross Payment Amount This Milestone",
"default": "undefined"
},
"adjustedHoldbackAmount": {
"type": "number",
"title": "Holdback Amount This Milestone"
},
"adjustedNetAmount": {
"type": "number",
"title": "Net Payment Amount This Milestone"
"type": ["null", "number"],
"title": "Net Payment Amount This Milestone",
"default": "undefined"
},
"dateSentToCsnr": {
"type": "string",
"title": "Date Invoice Sent to CSNR"
"type": ["null", "string"],
"title": "Date Invoice Sent to CSNR",
"default": "undefined"
}
},
"required": ["maximumAmount"]
Expand All @@ -117,8 +122,9 @@
"title": "Milestone Type"
},
"totalEligibleExpenses": {
"type": "number",
"title": "Total Eligible Expenses"
"type": ["null", "number"],
"title": "Total Eligible Expenses",
"default": "undefined"
}
}
}
Expand Down
10 changes: 6 additions & 4 deletions schema/data/prod/json_schema/operator.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,16 @@
"title": "Trade Name"
},
"bcRegistryId": {
"type": "string",
"type": ["null", "string"],
"title": "BC Registry ID",
"pattern": "^[a-zA-Z]{1,3}[0-9]{7}$"
"pattern": "^[a-zA-Z]{1,3}[0-9]{7}$",
"default": "undefined"
},
"operatorCode": {
"type": "string",
"type": ["null", "string"],
"title": "Operator Code",
"pattern": "^[A-Z]{4}$"
"pattern": "^[A-Z]{4}$",
"default": "undefined"
}
}
}
Expand Down
25 changes: 15 additions & 10 deletions schema/data/prod/json_schema/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,14 @@
"title": "Project Description"
},
"projectType": {
"type": "string",
"title": "Project Type"
"type": ["null", "string"],
"title": "Project Type",
"default": "undefined"
},
"score": {
"type": "number",
"title": "Score"
"type": ["null", "number"],
"title": "Score",
"default": "undefined"
},
"operatorId": {
"type": "number",
Expand All @@ -62,16 +64,19 @@
"anyOf": "undefined"
},
"additionalSectorInformation": {
"type": "string",
"title": "Additional Sector Information"
"type": ["null", "string"],
"title": "Additional Sector Information",
"default": "undefined"
},
"contractNumber": {
"type": "string",
"title": "Contract Number"
"type": ["null", "string"],
"title": "Contract Number",
"default": "undefined"
},
"comments": {
"type": "string",
"title": "General Comments"
"type": ["null", "string"],
"title": "General Comments",
"default": "undefined"
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion schema/data/prod/json_schema/project_contact.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"properties": {
"contactId": {
"title": "Contact",
"type": "number"
"type": ["null", "number"],
"default": "undefined"
}
}
}
Expand Down
5 changes: 3 additions & 2 deletions schema/data/prod/json_schema/project_manager.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
"title": "Project Manager",
"properties": {
"cifUserId": {
"type": "number",
"title": "Project Manager"
"type": ["null", "number"],
"title": "Project Manager",
"default": "undefined"
}
}
}
Expand Down
19 changes: 12 additions & 7 deletions schema/data/prod/json_schema/project_summary_report.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,29 @@
"title": "Report Due Date"
},
"submittedDate": {
"type": "string",
"title": "Received Date"
"type": ["null", "string"],
"title": "Received Date",
"default": "undefined"
},
"comments": {
"type": "string",
"title": "General Comments"
"type": ["null", "string"],
"title": "General Comments",
"default": "undefined"
},
"projectSummaryReportPayment": {
"title": "Project Summary Report Payment",
"type": "number"
"type": ["null", "number"],
"default": "undefined"
},
"paymentNotes": {
"title": "Notes for the Payment",
"type": "string"
"type": ["null", "string"],
"default": "undefined"
},
"dateSentToCsnr": {
"title": "Date Invoice Sent to CSNR",
"type": "string"
"type": ["null", "string"],
"default": "undefined"
}
}
}
Expand Down

0 comments on commit e84c8a1

Please sign in to comment.