summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--language/aws/spec.scm18
1 files changed, 13 insertions, 5 deletions
diff --git a/language/aws/spec.scm b/language/aws/spec.scm
index 836e4c6..2b63606 100644
--- a/language/aws/spec.scm
+++ b/language/aws/spec.scm
@@ -41,11 +41,19 @@ if this is not a primitive data type."
(match (assoc-ref exp "type")
("string"
(let ((enum (and=> (assoc-ref exp "enum")
- vector->list)))
- (if enum
- `(lambda (value)
- (member value ',enum))
- 'string?)))
+ vector->list))
+ (min (assoc-ref exp "min"))
+ (max (assoc-ref exp "max")))
+ `(lambda (value)
+ (and (string? value)
+ ,(if enum
+ `(member value ',enum)
+ #true)
+ ,(if (or min max)
+ `(let ((len (string-length value)))
+ (and ,(if min `(>= len ,min) #true)
+ ,(if max `(<= len ,max) #true)))
+ #true)))))
("blob" 'bytevector?)
("boolean" 'boolean?)
("timestamp" 'date?)