aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2019-05-19 21:26:14 +0100
committerChristopher Baines <mail@cbaines.net>2019-05-19 21:26:14 +0100
commit9f94e3278eb0b9df82d0035e19476498ad2c3484 (patch)
tree66b216f3dd2ec359ecc3c538f75289b002099632
parent78fb3fafc03617ff8a1427b8928e603d5a6307a6 (diff)
downloaddata-service-9f94e3278eb0b9df82d0035e19476498ad2c3484.tar
data-service-9f94e3278eb0b9df82d0035e19476498ad2c3484.tar.gz
Improve the query-parameters module for checkbox support
-rw-r--r--guix-data-service/web/query-parameters.scm5
1 files changed, 5 insertions, 0 deletions
diff --git a/guix-data-service/web/query-parameters.scm b/guix-data-service/web/query-parameters.scm
index dbf2e65..41e9beb 100644
--- a/guix-data-service/web/query-parameters.scm
+++ b/guix-data-service/web/query-parameters.scm
@@ -40,6 +40,7 @@
query-parameters->string
parse-datetime
+ parse-checkbox-value
parse-result-limit))
(define (parse-query-string query)
@@ -161,6 +162,7 @@
(define (value->text value)
(match value
(#f "")
+ (#t "on")
((? date? date)
(date->string date "~1 ~3"))
(other other)))
@@ -191,6 +193,9 @@
(lambda (key . args)
(make-invalid-query-parameter s #f))))
+(define (parse-checkbox-value s)
+ (string=? s "on"))
+
(define (parse-result-limit s)
(match (string->number s)
(#f (make-invalid-query-parameter s #f))