In the realm of simple crud apps made with ring and reitit, I’ve had what seems like an unreasonable amount of trouble dealing with form data from let’s say a group of checkboxes. E.g. make=saturn&model=&erg_or_qrg=QRG&year=2002&year=2003&year=2004&year=2005&year=2007&year=2008&url-presence=all, or printed nicely:
make: saturn
model:
erg_or_qrg: QRG
year: 2002
year: 2003
year: 2004
year: 2005
year: 2007
year: 2008
url-presence: all
I’ve been unable to avoid writing “custom” code to deal with the possibility of year appearing 0, 1, or 2+ times. To this end I tried reitit’s coercion feature with malli:
[:year {:optional true}
[:or int? ;; accepts one year
[:vector int?]]]
This works but the value exposed to the handler will be, e.g. 2020 or [2020 2021 2022] , which leaves me to deal with it in the handler. IMO it’s hardly worth using coercion in this case. Can my spec be improved to handle this, or is there another way, or am I missing something else entirely?This feels more like a Reitit question, but you could add some separate Ring middleware to force particular parameters to be vectors.