summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarius Peter <dev@marius-peter.com>2025-11-13 16:15:05 +0100
committerMarius Peter <dev@marius-peter.com>2025-11-13 16:15:05 +0100
commit7b09445140983623173203c4594bb54dcd55fe1e (patch)
tree855bab6b634130367cc22a22a9fc52e755ab2c0e
parent36b3bd1009e5cbd8545b6abbb5988c00d7274c15 (diff)
Add nutrient-value-pair/c contract.
-rw-r--r--models/nutrient.rkt9
1 files changed, 7 insertions, 2 deletions
diff --git a/models/nutrient.rkt b/models/nutrient.rkt
index 10e274e..944583e 100644
--- a/models/nutrient.rkt
+++ b/models/nutrient.rkt
@@ -1,12 +1,14 @@
#lang racket
(provide
- ;; Struct definitions
+ ;; Model struct
nutrient
nutrient?
nutrient-id nutrient-name nutrient-formula
- ;; SQL CRUD
+ ;; Contracts
+ nutrient-value-pair/c
(contract-out
+ ;; SQL CRUD
[create-nutrient! (-> string? string? nutrient?)]
[get-nutrients (-> (listof nutrient?))]
[get-nutrient (->* ()
@@ -33,6 +35,9 @@
(nutrient-id v)
(nutrient-name v))))
+(define nutrient-value-pair/c
+ (cons/c nutrient? (and/c real? (>=/c 0))))
+
;; CREATE
Copyright 2019--2026 Marius PETER