Fork me on GitHub
#ring-swagger
<
2016-01-26
>
jefmsmit16:01:17

I'm using compojure-api and trying to validate a query param as a number in a range. The number part is fine, but how about the range? So far I have {pageSize :- (ring-schema/describe Integer "number of results to return") 20}

juhoteperi16:01:07

With s/constrained you can combine a Schema with a function: (s/constrained Integer (fn [x] (<= 1 x 9000)))

juhoteperi16:01:30

Compared to just using s/pred this enables coercion per Integer Schema

jefmsmit16:01:22

@ljosa, I saw that article but it didn't play nice with defining a schema inline for a query-parameter

jefmsmit18:01:50

@ikitommi: almost exactly what I ended up with too. Thanks for the snippet.