Fork me on GitHub
#ring-swagger
<
2018-12-03
>
Daouda14:12:19

heys folks, any way to set constrained between two keys of the same schema?

ikitommi16:12:40

@quieterkali try s/constrained with schema and a custom function.

Daouda16:12:43

ok @ikitommi will try that now ๐Ÿ™‚

Daouda16:12:00

what i am doing wrong here please?

(s/defschema ProfileConnector
  "Schema for profile's connexion"
  {:profile-one IdProfile
   :profile-two (s/constrained IdProfile #(not (= :profile-one %)))})

Daouda16:12:31

validation is not being applied ๐Ÿ˜ž

Daouda16:12:30

IdProfile is another costum validation and is working fine

ikitommi16:12:09

You need to constrain the map-schema.

Daouda16:12:44

i'll be right back

๐Ÿ™ 4
Daouda16:12:49

thanks ๐Ÿ™‚

ikitommi17:12:16

(s/constrained
  {:profile-one IdProfile
   :profile-two IdProfile}
  #(not= (:profile-one %) (:profile-two %))
  'profiles-should-differ)

๐Ÿ‘ 4
Daouda17:12:02

@ikitommi you saved my day, thank you very much ๐Ÿ™‚

Daouda17:12:03

and i learnt that i can consstrained the whole schema, this is very very very handy

ikitommi17:12:05

happy to help

florinbraghis19:12:25

Hello channel ! If I do this :body-params [x :- Long y :- Long] in a request handler, then the โ€˜parametersโ€™ value in swagger.json contains a generated schema, which is named something like Body17343, which contains my x and y definitions. Is there a way to give this automatic schema a name, while preserving the x and y bindings ?