From e3e3b87379b7f3a4fef665ed2375a35afa5adcfd Mon Sep 17 00:00:00 2001 From: Michiel de Mare Date: Wed, 12 Jun 2024 17:04:05 +0200 Subject: [PATCH] Removed limit on admissionRequirements (#312) * Removed limit on admissionRequirements * Unlimited language string --- src/nl/surf/eduhub_rio_mapper/specs/common.clj | 15 +++++++++++++++ src/nl/surf/eduhub_rio_mapper/specs/program.clj | 2 +- .../surf/eduhub_rio_mapper/ooapi/program_test.clj | 5 +++++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/nl/surf/eduhub_rio_mapper/specs/common.clj b/src/nl/surf/eduhub_rio_mapper/specs/common.clj index a3799123..e00ecc03 100644 --- a/src/nl/surf/eduhub_rio_mapper/specs/common.clj +++ b/src/nl/surf/eduhub_rio_mapper/specs/common.clj @@ -20,6 +20,7 @@ "Common specs for use in the ooapi namespaces." (:require [clojure.spec.alpha :as s] [nl.surf.eduhub-rio-mapper.ooapi.common.LongLanguageTypedString :as-alias LongLanguageTypedString] + [nl.surf.eduhub-rio-mapper.ooapi.common.UnlimitedLanguageTypedString :as-alias UnlimitedLanguageTypedString] [nl.surf.eduhub-rio-mapper.ooapi.enums :as enums] [nl.surf.eduhub-rio-mapper.ooapi.LanguageTypedString :as-alias LanguageTypedString] [nl.surf.eduhub-rio-mapper.ooapi.LanguageTypedStringEN :as-alias LanguageTypedStringEN] @@ -121,6 +122,20 @@ (s/def ::LongLanguageTypedStrings (s/coll-of ::LongLanguageTypedString)) +(s/def ::UnlimitedLanguageTypedString/language + (re-spec #"^[a-z]{2,4}(-[A-Z][a-z]{3})?(-([A-Z]{2}|[0-9]{3}))?$")) + +(s/def ::UnlimitedLanguageTypedString/value + string?) + +(s/def ::UnlimitedLanguageTypedString + (s/keys :req-un [::UnlimitedLanguageTypedString/language + ::UnlimitedLanguageTypedString/value])) + +;; A collection of language typed strings with any set of languages +(s/def ::UnlimitedLanguageTypedStrings + (s/coll-of ::UnlimitedLanguageTypedString)) + ;; A collection of language typed strings with at least one dutch or ;; english entry (s/def ::nlOrEnLanguageTypedStrings diff --git a/src/nl/surf/eduhub_rio_mapper/specs/program.clj b/src/nl/surf/eduhub_rio_mapper/specs/program.clj index e45554ef..49c2a1bb 100644 --- a/src/nl/surf/eduhub_rio_mapper/specs/program.clj +++ b/src/nl/surf/eduhub_rio_mapper/specs/program.clj @@ -26,7 +26,7 @@ (text-spec 1 40)) (s/def ::acceleratedRoute enums/acceleratedRoute) -(s/def ::admissionRequirements ::common/LanguageTypedStrings) +(s/def ::admissionRequirements ::common/UnlimitedLanguageTypedStrings) (s/def ::assessment ::common/LanguageTypedStrings) (s/def ::children (s/coll-of ::common/uuid)) (s/def ::consentParticipationSTAP enums/consentParticipationSTAP) diff --git a/test/nl/surf/eduhub_rio_mapper/ooapi/program_test.clj b/test/nl/surf/eduhub_rio_mapper/ooapi/program_test.clj index 0783cfae..28d8969b 100644 --- a/test/nl/surf/eduhub_rio_mapper/ooapi/program_test.clj +++ b/test/nl/surf/eduhub_rio_mapper/ooapi/program_test.clj @@ -54,6 +54,11 @@ (let [{::s/keys [problems]} (s/explain-data ::prg/rio-consumer (assoc rio-consumer :educationOffererCode "123B123"))] (is (= :educationOffererCode (-> problems first :path first))))) +(deftest dont-validate-admission-reqs + (let [{::s/keys [problems]} (s/explain-data ::prg/program (assoc-in program [:admissionRequirements 0 :value] + (apply str (take 1010 (repeatedly #(char (+ (rand-int 26) 97)))))))] + (is (contains? #{nil []} problems)))) + (deftest validate-consumers (let [{::s/keys [problems]} (s/explain-data ::prg/consumers [other-consumer rio-consumer])] (is (contains? #{nil []} problems))))