Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed limit on admissionRequirements #312

Merged
merged 2 commits into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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