Skip to content

Commit

Permalink
Removed limit on admissionRequirements (#312)
Browse files Browse the repository at this point in the history
* Removed limit on admissionRequirements

* Unlimited language string
  • Loading branch information
mdemare authored Jun 12, 2024
1 parent dc10389 commit e3e3b87
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
15 changes: 15 additions & 0 deletions src/nl/surf/eduhub_rio_mapper/specs/common.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/nl/surf/eduhub_rio_mapper/specs/program.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 5 additions & 0 deletions test/nl/surf/eduhub_rio_mapper/ooapi/program_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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))))
Expand Down

0 comments on commit e3e3b87

Please sign in to comment.