From 63b42a3d1ca25539243ee1ed744d01122a414b99 Mon Sep 17 00:00:00 2001 From: Kaden Emley <104032811+kemley76@users.noreply.github.com> Date: Thu, 11 Jul 2024 13:53:04 -0400 Subject: [PATCH] checklist metadata input validation on export (#5902) * checklist metadata input validation on export Signed-off-by: kemley76 * update lock file * added @types/validator Signed-off-by: kemley76 * move throwIfInvalid() to not be inline Signed-off-by: kemley76 * remove @types/validator from devDependencies Signed-off-by: kemley76 * validate all metadata fields on checklist metadata Signed-off-by: kemley76 * Merge branch 'master' into ckl-metadata-validation Signed-off-by: kemley76 * refactor nested template strings Signed-off-by: kemley76 * refactor checklist metadata validation assertions Signed-off-by: kemley76 * cleaned up input validation error messaging on ckl export modal Signed-off-by: Kaden Emley * restrict number inputs to positive integers in ckl export modal Signed-off-by: Kaden Emley * added combined ckl metadata validation methods into single helper method Signed-off-by: Kaden Emley * remove repeated imports of the same file Signed-off-by: Kaden Emley * Merge branch 'master' into ckl-metadata-validation Signed-off-by: Kaden Emley * minor formatting change Signed-off-by: Kaden Emley * make checklist metadata date validator accept more formats Signed-off-by: Kaden Emley * swapped error message for format hint in ckl export modal Signed-off-by: Kaden Emley * move vul id mapping info icon to allow dropdown arrow to show Signed-off-by: Kaden Emley * refine integer constraints on checklist export modal fields Signed-off-by: Kaden Emley * move metadata validation functions into util file Signed-off-by: Kaden Emley * add test to ensure errors are thrown upon using invalid checklist metadata Signed-off-by: Kaden Emley * remove unused import Signed-off-by: Kaden Emley --------- Signed-off-by: kemley76 Signed-off-by: Kaden Emley Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> --- .../src/components/global/ExportCKLModal.vue | 100 +++- libs/hdf-converters/index.ts | 1 + libs/hdf-converters/package.json | 4 + .../sample_input_report/invalid_metadata.ckl | 505 ++++++++++++++++++ .../sample_input_report/invalid_metadata.json | 1 + .../ckl-mapper/checklist-jsonix-converter.ts | 5 +- .../src/ckl-mapper/checklist-mapper.ts | 5 + .../ckl-mapper/checklist-metadata-utils.ts | 142 +++++ libs/hdf-converters/src/utils/result.ts | 1 + .../mappers/forward/checklist_mapper.spec.ts | 14 + .../reverse/checklist_reverse_mapper.spec.ts | 16 + yarn.lock | 20 +- 12 files changed, 786 insertions(+), 28 deletions(-) create mode 100644 libs/hdf-converters/sample_jsons/checklist_mapper/sample_input_report/invalid_metadata.ckl create mode 100644 libs/hdf-converters/sample_jsons/checklist_mapper/sample_input_report/invalid_metadata.json create mode 100644 libs/hdf-converters/src/ckl-mapper/checklist-metadata-utils.ts create mode 100644 libs/hdf-converters/src/utils/result.ts diff --git a/apps/frontend/src/components/global/ExportCKLModal.vue b/apps/frontend/src/components/global/ExportCKLModal.vue index 0c6d42eab3..aeb7daa5e6 100644 --- a/apps/frontend/src/components/global/ExportCKLModal.vue +++ b/apps/frontend/src/components/global/ExportCKLModal.vue @@ -61,20 +61,37 @@ - +