Skip to content

Commit

Permalink
OK-555 validate either due-date or due-days
Browse files Browse the repository at this point in the history
  • Loading branch information
vaeinoe committed Sep 24, 2024
1 parent 8b8814c commit 3e4e2c6
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions src/cljc/maksut/api_schemas.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,21 @@
:index (s/constrained s/Int #(<= 1 % 2) 'valid-tutu-maksu-index)})

(s/defschema LaskuCreate
{(s/optional-key :order-id) s/Str
:first-name s/Str
:last-name s/Str
:email s/Str
:amount s/Str
(s/optional-key :due-date) (s/maybe s/Str) ;If not defined, then due-days used
:due-days (s/constrained s/Int #(> % 0) 'positive-due-days)
:origin Origin
:reference s/Str
(s/optional-key :index) (s/constrained s/Int #(<= 1 % 2) 'valid-tutu-maksu-index)})
(s/constrained
{(s/optional-key :order-id) s/Str
:first-name s/Str
:last-name s/Str
:email s/Str
:amount s/Str
(s/optional-key :due-date) (s/maybe s/Str)
(s/optional-key :due-days) (s/constrained s/Int #(> % 0) 'positive-due-days)
:origin Origin
:reference s/Str
(s/optional-key :index) (s/constrained s/Int #(<= 1 % 2) 'valid-tutu-maksu-index)}
(fn [{:keys [due-date due-days]}]
(or due-date due-days))
'must-have-either-due-date-or-due-days))


(s/defschema LaskuStatus
{:order-id s/Str
Expand Down

0 comments on commit 3e4e2c6

Please sign in to comment.