File tree Expand file tree Collapse file tree 1 file changed +8
-3
lines changed
libs/wire-api/src/Wire/API/Team Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -354,7 +354,12 @@ data FeatureTTL
354
354
= FeatureTTLSeconds Word
355
355
| FeatureTTLUnlimited
356
356
deriving stock (Eq , Show , Generic )
357
- deriving (Arbitrary ) via (GenericUniform FeatureTTL )
357
+
358
+ instance Arbitrary FeatureTTL where
359
+ arbitrary = nonZero <$> arbitrary
360
+ where
361
+ nonZero 0 = FeatureTTLUnlimited
362
+ nonZero n = FeatureTTLSeconds n
358
363
359
364
instance ToSchema FeatureTTL where
360
365
schema = mkSchema ttlDoc toTTL fromTTL
@@ -376,9 +381,9 @@ instance ToSchema FeatureTTL where
376
381
parseSeconds :: A. Value -> A. Parser FeatureTTL
377
382
parseSeconds = A. withScientific " FeatureTTL" $
378
383
\ s -> case toBoundedInteger s of
379
- Just 0 -> pure FeatureTTLUnlimited
384
+ Just 0 -> A. parseFail " Expected a positive integer. Got 0 instead. "
380
385
Just i -> pure . FeatureTTLSeconds $ i
381
- Nothing -> A. parseFail " Expected an integer."
386
+ Nothing -> A. parseFail " Expected an positive integer."
382
387
383
388
fromTTL :: FeatureTTL -> Maybe A. Value
384
389
fromTTL FeatureTTLUnlimited = Just " unlimited"
You can’t perform that action at this time.
0 commit comments