Skip to content

Commit

Permalink
[ODS-6323] Minimum String Length enforced for optional data elements (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
gmcelhanon authored Apr 29, 2024
1 parent 020baf0 commit df003c7
Show file tree
Hide file tree
Showing 18 changed files with 1,726 additions and 1,607 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/Dependencies Security Scan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ name: Dependency Review Pull request

on:
pull_request:
branches: [main]
branches: [main, 'b-v*-patch*','feature-*']

env:
HEAD_REF: ${{ GITHUB.HEAD_REF }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ jobs:
echo "EXIT_STEP value is ${{ env.EXIT_STEP }}"
- name: Dispatch InitDev , Multitenancy workflow
if: env.EXIT_STEP != 'true'
uses: codex-/return-dispatch@290d1ad3ca0a323120745aea7a44ce63ed91a982 #v1.8.0
uses: codex-/return-dispatch@03a7fcd260cce601805567f86c892bd06d2719e1 #v1.12.0
id: return_dispatch_InitDevMultitenancy
with:
token: ${{ env.EDFI_ODS_IMP_TOKEN }}
Expand All @@ -107,7 +107,7 @@ jobs:
workflow_timeout_seconds: 4800
- name: Dispatch InitDev, Smoke Tests workflow
if: env.EXIT_STEP != 'true'
uses: codex-/return-dispatch@290d1ad3ca0a323120745aea7a44ce63ed91a982 #v1.8.0
uses: codex-/return-dispatch@03a7fcd260cce601805567f86c892bd06d2719e1 #v1.12.0
id: return_dispatch_InitDevSmokeTests
with:
token: ${{ env.EDFI_ODS_IMP_TOKEN }}
Expand All @@ -118,7 +118,7 @@ jobs:
workflow_timeout_seconds: 4800
- name: Dispatch InitDev, Unit tests, Integration tests, Package workflow
if: env.EXIT_STEP != 'true'
uses: codex-/return-dispatch@290d1ad3ca0a323120745aea7a44ce63ed91a982 #v1.8.0
uses: codex-/return-dispatch@03a7fcd260cce601805567f86c892bd06d2719e1 #v1.12.0
id: return_dispatch_InitDevUnittestsIntegrationtestsPackage
with:
token: ${{ env.EDFI_ODS_IMP_TOKEN }}
Expand All @@ -129,7 +129,7 @@ jobs:
workflow_timeout_seconds: 4800
- name: Dispatch InitDev Postgres, Multitenancy workflow
if: env.EXIT_STEP != 'true'
uses: codex-/return-dispatch@290d1ad3ca0a323120745aea7a44ce63ed91a982 #v1.8.0
uses: codex-/return-dispatch@03a7fcd260cce601805567f86c892bd06d2719e1 #v1.12.0
id: return_dispatch_InitDevPostgresMultitenancy
with:
token: ${{ env.EDFI_ODS_IMP_TOKEN }}
Expand All @@ -140,7 +140,7 @@ jobs:
workflow_timeout_seconds: 4800
- name: Dispatch InitDev Postgres, Smoke Tests workflow
if: env.EXIT_STEP != 'true'
uses: codex-/return-dispatch@290d1ad3ca0a323120745aea7a44ce63ed91a982 #v1.8.0
uses: codex-/return-dispatch@03a7fcd260cce601805567f86c892bd06d2719e1 #v1.12.0
id: return_dispatch_InitDevPostgresSmokeTests
with:
token: ${{ env.EDFI_ODS_IMP_TOKEN }}
Expand All @@ -151,7 +151,7 @@ jobs:
workflow_timeout_seconds: 4800
- name: Dispatch InitDev Postgres, Unit tests, Integration tests workflow
if: env.EXIT_STEP != 'true'
uses: codex-/return-dispatch@290d1ad3ca0a323120745aea7a44ce63ed91a982 #v1.8.0
uses: codex-/return-dispatch@03a7fcd260cce601805567f86c892bd06d2719e1 #v1.12.0
id: return_dispatch_InitDevPostgresUnittestsIntegrationtests
with:
token: ${{ env.EDFI_ODS_IMP_TOKEN }}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// SPDX-License-Identifier: Apache-2.0
// Licensed to the Ed-Fi Alliance under one or more agreements.
// The Ed-Fi Alliance licenses this file to you under the Apache License, Version 2.0.
// See the LICENSE and NOTICES files in the project root for more information.

using System.ComponentModel.DataAnnotations;

namespace EdFi.Ods.Common.Attributes;

public class NonDefaultStringLengthAttribute : StringLengthAttribute
{
public NonDefaultStringLengthAttribute(int maximumLength)
: base(maximumLength) { }

public override bool IsValid(object value)
{
// Skip the validation if the string is either null or empty.
if (string.IsNullOrEmpty((string) value))
{
return true;
}

return base.IsValid(value);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7422,6 +7422,100 @@
{
"name": "String Length",
"item": [
{
"name": "Optional Empty String",
"item": [
{
"name": "Create Staff with optional string empty (middle name)",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 201\", () => {\r",
" pm.expect(pm.response.code).to.equal(201);\r",
"});\r",
"\r",
"pm.environment.set('known:staff:id', pm.response.headers.one('Location').value.split(\"/\").pop());"
],
"type": "text/javascript",
"packages": {}
}
}
],
"request": {
"method": "POST",
"header": [],
"body": {
"mode": "raw",
"raw": " {\r\n \"staffUniqueId\": \"TEST-Optional-String-Empty\",\r\n \"birthDate\": \"1976-08-19\",\r\n \"firstName\": \"Barry\",\r\n \"middleName\": \"\",\r\n \"highestCompletedLevelOfEducationDescriptor\": \"uri://ed-fi.org/LevelOfEducationDescriptor#Master's\",\r\n \"hispanicLatinoEthnicity\": false,\r\n \"lastSurname\": \"Tanner\",\r\n \"loginId\": \"btanner\",\r\n \"personalTitlePrefix\": \"Mr\",\r\n \"sexDescriptor\": \"uri://ed-fi.org/SexDescriptor#Male\",\r\n \"yearsOfPriorProfessionalExperience\": 30.00\r\n }",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{ApiBaseUrl}}/data/v3/ed-fi/staffs",
"host": [
"{{ApiBaseUrl}}"
],
"path": [
"data",
"v3",
"ed-fi",
"staffs"
]
}
},
"response": []
},
{
"name": "Delete the Staff",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 204\", () => {\r",
" pm.expect(pm.response.code).to.equal(204);\r",
"});\r",
""
],
"type": "text/javascript"
}
}
],
"request": {
"method": "DELETE",
"header": [],
"body": {
"mode": "raw",
"raw": "",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{ApiBaseUrl}}/data/v3/ed-fi/staffs/{{known:staff:id}}",
"host": [
"{{ApiBaseUrl}}"
],
"path": [
"data",
"v3",
"ed-fi",
"staffs",
"{{known:staff:id}}"
]
}
},
"response": []
}
]
},
{
"name": "Create Staff with Pet with name too short",
"event": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,9 @@ public Name()
// =============================================================
// Primary Key
// -------------------------------------------------------------
[DomainSignature, RequiredWithNonDefault, StringLength(75, MinimumLength=1), NoDangerousText, NoWhitespace]
[DomainSignature, RequiredWithNonDefault, NonDefaultStringLength(75, MinimumLength=1), NoDangerousText, NoWhitespace]
public virtual string FirstName { get; set; }
[DomainSignature, RequiredWithNonDefault, StringLength(75, MinimumLength=1), NoDangerousText, NoWhitespace]
[DomainSignature, RequiredWithNonDefault, NonDefaultStringLength(75, MinimumLength=1), NoDangerousText, NoWhitespace]
public virtual string LastSurname { get; set; }
// -------------------------------------------------------------

Expand Down Expand Up @@ -358,9 +358,9 @@ public Parent()
// =============================================================
// Primary Key
// -------------------------------------------------------------
[DomainSignature, RequiredWithNonDefault, StringLength(75, MinimumLength=1), NoDangerousText, NoWhitespace]
[DomainSignature, RequiredWithNonDefault, NonDefaultStringLength(75, MinimumLength=1), NoDangerousText, NoWhitespace]
public virtual string ParentFirstName { get; set; }
[DomainSignature, RequiredWithNonDefault, StringLength(75, MinimumLength=1), NoDangerousText, NoWhitespace]
[DomainSignature, RequiredWithNonDefault, NonDefaultStringLength(75, MinimumLength=1), NoDangerousText, NoWhitespace]
public virtual string ParentLastSurname { get; set; }
// -------------------------------------------------------------

Expand Down Expand Up @@ -634,7 +634,7 @@ Entities.Common.Homograph.IParent IParentAddress.Parent
set { Parent = (Parent) value; }
}

[DomainSignature, RequiredWithNonDefault, StringLength(30, MinimumLength=2), NoDangerousText, NoWhitespace]
[DomainSignature, RequiredWithNonDefault, NonDefaultStringLength(30, MinimumLength=2), NoDangerousText, NoWhitespace]
public virtual string City { get; set; }
// -------------------------------------------------------------

Expand Down Expand Up @@ -793,11 +793,11 @@ Entities.Common.Homograph.IParent IParentStudentSchoolAssociation.Parent
set { Parent = (Parent) value; }
}

[DomainSignature, RequiredWithNonDefault, StringLength(100, MinimumLength=0), NoDangerousText, NoWhitespace]
[DomainSignature, RequiredWithNonDefault, NonDefaultStringLength(100, MinimumLength=0), NoDangerousText, NoWhitespace]
public virtual string SchoolName { get; set; }
[DomainSignature, RequiredWithNonDefault, StringLength(75, MinimumLength=1), NoDangerousText, NoWhitespace]
[DomainSignature, RequiredWithNonDefault, NonDefaultStringLength(75, MinimumLength=1), NoDangerousText, NoWhitespace]
public virtual string StudentFirstName { get; set; }
[DomainSignature, RequiredWithNonDefault, StringLength(75, MinimumLength=1), NoDangerousText, NoWhitespace]
[DomainSignature, RequiredWithNonDefault, NonDefaultStringLength(75, MinimumLength=1), NoDangerousText, NoWhitespace]
public virtual string StudentLastSurname { get; set; }
// -------------------------------------------------------------

Expand Down Expand Up @@ -1051,7 +1051,7 @@ public School()
// =============================================================
// Primary Key
// -------------------------------------------------------------
[DomainSignature, RequiredWithNonDefault, StringLength(100, MinimumLength=0), NoDangerousText, NoWhitespace]
[DomainSignature, RequiredWithNonDefault, NonDefaultStringLength(100, MinimumLength=0), NoDangerousText, NoWhitespace]
public virtual string SchoolName { get; set; }
// -------------------------------------------------------------

Expand All @@ -1063,7 +1063,7 @@ public School()
// =============================================================
// Properties
// -------------------------------------------------------------
[StringLength(20, MinimumLength=0), NoDangerousText]
[NonDefaultStringLength(20, MinimumLength=0), NoDangerousText]
public virtual string SchoolYear { get; set; }
// -------------------------------------------------------------

Expand Down Expand Up @@ -1297,7 +1297,7 @@ Entities.Common.Homograph.ISchool ISchoolAddress.School
// =============================================================
// Properties
// -------------------------------------------------------------
[RequiredWithNonDefault, StringLength(30, MinimumLength=2), NoDangerousText]
[RequiredWithNonDefault, NonDefaultStringLength(30, MinimumLength=2), NoDangerousText]
public virtual string City { get; set; }
// -------------------------------------------------------------

Expand Down Expand Up @@ -1517,7 +1517,7 @@ public SchoolYearType()
// =============================================================
// Primary Key
// -------------------------------------------------------------
[DomainSignature, RequiredWithNonDefault, StringLength(20, MinimumLength=0), NoDangerousText, NoWhitespace]
[DomainSignature, RequiredWithNonDefault, NonDefaultStringLength(20, MinimumLength=0), NoDangerousText, NoWhitespace]
public virtual string SchoolYear { get; set; }
// -------------------------------------------------------------

Expand Down Expand Up @@ -1748,9 +1748,9 @@ public Staff()
// =============================================================
// Primary Key
// -------------------------------------------------------------
[DomainSignature, RequiredWithNonDefault, StringLength(75, MinimumLength=1), NoDangerousText, NoWhitespace]
[DomainSignature, RequiredWithNonDefault, NonDefaultStringLength(75, MinimumLength=1), NoDangerousText, NoWhitespace]
public virtual string StaffFirstName { get; set; }
[DomainSignature, RequiredWithNonDefault, StringLength(75, MinimumLength=1), NoDangerousText, NoWhitespace]
[DomainSignature, RequiredWithNonDefault, NonDefaultStringLength(75, MinimumLength=1), NoDangerousText, NoWhitespace]
public virtual string StaffLastSurname { get; set; }
// -------------------------------------------------------------

Expand Down Expand Up @@ -2022,7 +2022,7 @@ Entities.Common.Homograph.IStaff IStaffAddress.Staff
set { Staff = (Staff) value; }
}

[DomainSignature, RequiredWithNonDefault, StringLength(30, MinimumLength=2), NoDangerousText, NoWhitespace]
[DomainSignature, RequiredWithNonDefault, NonDefaultStringLength(30, MinimumLength=2), NoDangerousText, NoWhitespace]
public virtual string City { get; set; }
// -------------------------------------------------------------

Expand Down Expand Up @@ -2181,11 +2181,11 @@ Entities.Common.Homograph.IStaff IStaffStudentSchoolAssociation.Staff
set { Staff = (Staff) value; }
}

[DomainSignature, RequiredWithNonDefault, StringLength(100, MinimumLength=0), NoDangerousText, NoWhitespace]
[DomainSignature, RequiredWithNonDefault, NonDefaultStringLength(100, MinimumLength=0), NoDangerousText, NoWhitespace]
public virtual string SchoolName { get; set; }
[DomainSignature, RequiredWithNonDefault, StringLength(75, MinimumLength=1), NoDangerousText, NoWhitespace]
[DomainSignature, RequiredWithNonDefault, NonDefaultStringLength(75, MinimumLength=1), NoDangerousText, NoWhitespace]
public virtual string StudentFirstName { get; set; }
[DomainSignature, RequiredWithNonDefault, StringLength(75, MinimumLength=1), NoDangerousText, NoWhitespace]
[DomainSignature, RequiredWithNonDefault, NonDefaultStringLength(75, MinimumLength=1), NoDangerousText, NoWhitespace]
public virtual string StudentLastSurname { get; set; }
// -------------------------------------------------------------

Expand Down Expand Up @@ -2441,9 +2441,9 @@ public Student()
// =============================================================
// Primary Key
// -------------------------------------------------------------
[DomainSignature, RequiredWithNonDefault, StringLength(75, MinimumLength=1), NoDangerousText, NoWhitespace]
[DomainSignature, RequiredWithNonDefault, NonDefaultStringLength(75, MinimumLength=1), NoDangerousText, NoWhitespace]
public virtual string StudentFirstName { get; set; }
[DomainSignature, RequiredWithNonDefault, StringLength(75, MinimumLength=1), NoDangerousText, NoWhitespace]
[DomainSignature, RequiredWithNonDefault, NonDefaultStringLength(75, MinimumLength=1), NoDangerousText, NoWhitespace]
public virtual string StudentLastSurname { get; set; }
// -------------------------------------------------------------

Expand All @@ -2455,7 +2455,7 @@ public Student()
// =============================================================
// Properties
// -------------------------------------------------------------
[RequiredWithNonDefault, StringLength(20, MinimumLength=0), NoDangerousText]
[RequiredWithNonDefault, NonDefaultStringLength(20, MinimumLength=0), NoDangerousText]
public virtual string SchoolYear { get; set; }
// -------------------------------------------------------------

Expand Down Expand Up @@ -2700,7 +2700,7 @@ Entities.Common.Homograph.IStudent IStudentAddress.Student
set { Student = (Student) value; }
}

[DomainSignature, RequiredWithNonDefault, StringLength(30, MinimumLength=2), NoDangerousText, NoWhitespace]
[DomainSignature, RequiredWithNonDefault, NonDefaultStringLength(30, MinimumLength=2), NoDangerousText, NoWhitespace]
public virtual string City { get; set; }
// -------------------------------------------------------------

Expand Down Expand Up @@ -2935,11 +2935,11 @@ public StudentSchoolAssociation()
// =============================================================
// Primary Key
// -------------------------------------------------------------
[DomainSignature, RequiredWithNonDefault, StringLength(100, MinimumLength=0), NoDangerousText, NoWhitespace]
[DomainSignature, RequiredWithNonDefault, NonDefaultStringLength(100, MinimumLength=0), NoDangerousText, NoWhitespace]
public virtual string SchoolName { get; set; }
[DomainSignature, RequiredWithNonDefault, StringLength(75, MinimumLength=1), NoDangerousText, NoWhitespace]
[DomainSignature, RequiredWithNonDefault, NonDefaultStringLength(75, MinimumLength=1), NoDangerousText, NoWhitespace]
public virtual string StudentFirstName { get; set; }
[DomainSignature, RequiredWithNonDefault, StringLength(75, MinimumLength=1), NoDangerousText, NoWhitespace]
[DomainSignature, RequiredWithNonDefault, NonDefaultStringLength(75, MinimumLength=1), NoDangerousText, NoWhitespace]
public virtual string StudentLastSurname { get; set; }
// -------------------------------------------------------------

Expand Down
Loading

0 comments on commit df003c7

Please sign in to comment.