@@ -145,7 +145,9 @@ validateCBOR' bs rule cddl@(CTreeRoot tree) =
145
145
-- spec
146
146
validateTerm ::
147
147
MonadReader CDDL m =>
148
- Term -> Rule -> m CBORTermResult
148
+ Term ->
149
+ Rule ->
150
+ m CBORTermResult
149
151
validateTerm term rule =
150
152
let f = case term of
151
153
TInt i -> validateInteger (fromIntegral i)
@@ -183,7 +185,9 @@ validateTerm term rule =
183
185
-- Ints, so we convert everything to Integer.
184
186
validateInteger ::
185
187
MonadReader CDDL m =>
186
- Integer -> Rule -> m CDDLResult
188
+ Integer ->
189
+ Rule ->
190
+ m CDDLResult
187
191
validateInteger i rule =
188
192
($ rule) <$> do
189
193
getRule rule >>= \ case
@@ -308,7 +312,9 @@ controlInteger i Ne ctrl =
308
312
-- | Validating a `Float16`
309
313
validateHalf ::
310
314
MonadReader CDDL m =>
311
- Float -> Rule -> m CDDLResult
315
+ Float ->
316
+ Rule ->
317
+ m CDDLResult
312
318
validateHalf f rule =
313
319
($ rule) <$> do
314
320
getRule rule >>= \ case
@@ -343,7 +349,9 @@ controlHalf f Ne ctrl =
343
349
-- | Validating a `Float32`
344
350
validateFloat ::
345
351
MonadReader CDDL m =>
346
- Float -> Rule -> m CDDLResult
352
+ Float ->
353
+ Rule ->
354
+ m CDDLResult
347
355
validateFloat f rule =
348
356
($ rule) <$> do
349
357
getRule rule >>= \ case
@@ -383,7 +391,9 @@ controlFloat f Ne ctrl =
383
391
-- | Validating a `Float64`
384
392
validateDouble ::
385
393
MonadReader CDDL m =>
386
- Double -> Rule -> m CDDLResult
394
+ Double ->
395
+ Rule ->
396
+ m CDDLResult
387
397
validateDouble f rule =
388
398
($ rule) <$> do
389
399
getRule rule >>= \ case
@@ -430,7 +440,9 @@ controlDouble f Ne ctrl =
430
440
-- | Validating a boolean
431
441
validateBool ::
432
442
MonadReader CDDL m =>
433
- Bool -> Rule -> m CDDLResult
443
+ Bool ->
444
+ Rule ->
445
+ m CDDLResult
434
446
validateBool b rule =
435
447
($ rule) <$> do
436
448
getRule rule >>= \ case
@@ -463,7 +475,9 @@ controlBool b Ne ctrl =
463
475
-- | Validating a `TSimple`. It is unclear if this is used for anything else than undefined.
464
476
validateSimple ::
465
477
MonadReader CDDL m =>
466
- Word8 -> Rule -> m CDDLResult
478
+ Word8 ->
479
+ Rule ->
480
+ m CDDLResult
467
481
validateSimple 23 rule =
468
482
($ rule) <$> do
469
483
getRule rule >>= \ case
@@ -498,7 +512,9 @@ validateNull rule =
498
512
-- | Validating a byte sequence
499
513
validateBytes ::
500
514
MonadReader CDDL m =>
501
- BS. ByteString -> Rule -> m CDDLResult
515
+ BS. ByteString ->
516
+ Rule ->
517
+ m CDDLResult
502
518
validateBytes bs rule =
503
519
($ rule) <$> do
504
520
getRule rule >>= \ case
@@ -517,7 +533,11 @@ validateBytes bs rule =
517
533
-- | Controls for byte strings
518
534
controlBytes ::
519
535
forall m .
520
- MonadReader CDDL m => BS. ByteString -> CtlOp -> Rule -> m (Either (Maybe CBORTermResult ) () )
536
+ MonadReader CDDL m =>
537
+ BS. ByteString ->
538
+ CtlOp ->
539
+ Rule ->
540
+ m (Either (Maybe CBORTermResult ) () )
521
541
controlBytes bs Size ctrl =
522
542
getRule ctrl >>= \ case
523
543
Literal (Value (VUInt (fromIntegral -> sz)) _) -> pure $ boolCtrl $ BS. length bs == sz
@@ -568,7 +588,9 @@ controlBytes bs Cborseq ctrl =
568
588
-- | Validating text strings
569
589
validateText ::
570
590
MonadReader CDDL m =>
571
- T. Text -> Rule -> m CDDLResult
591
+ T. Text ->
592
+ Rule ->
593
+ m CDDLResult
572
594
validateText txt rule =
573
595
($ rule) <$> do
574
596
getRule rule >>= \ case
@@ -607,7 +629,10 @@ controlText s Regexp ctrl =
607
629
-- | Validating a `TTagged`
608
630
validateTagged ::
609
631
MonadReader CDDL m =>
610
- Word64 -> Term -> Rule -> m CDDLResult
632
+ Word64 ->
633
+ Term ->
634
+ Rule ->
635
+ m CDDLResult
611
636
validateTagged tag term rule =
612
637
($ rule) <$> do
613
638
getRule rule >>= \ case
@@ -725,7 +750,9 @@ isOptional rule =
725
750
validateListWithExpandedRules ::
726
751
forall m .
727
752
MonadReader CDDL m =>
728
- [Term ] -> [Rule ] -> m [(Rule , CBORTermResult )]
753
+ [Term ] ->
754
+ [Rule ] ->
755
+ m [(Rule , CBORTermResult )]
729
756
validateListWithExpandedRules terms rules =
730
757
go (zip terms rules)
731
758
where
@@ -795,7 +822,9 @@ validateList terms rule =
795
822
validateMapWithExpandedRules ::
796
823
forall m .
797
824
MonadReader CDDL m =>
798
- [(Term , Term )] -> [Rule ] -> m ([AMatchedItem ], Maybe ANonMatchedItem )
825
+ [(Term , Term )] ->
826
+ [Rule ] ->
827
+ m ([AMatchedItem ], Maybe ANonMatchedItem )
799
828
validateMapWithExpandedRules =
800
829
go
801
830
where
@@ -853,7 +882,9 @@ validateExpandedMap terms rules = go rules
853
882
854
883
validateMap ::
855
884
MonadReader CDDL m =>
856
- [(Term , Term )] -> Rule -> m CDDLResult
885
+ [(Term , Term )] ->
886
+ Rule ->
887
+ m CDDLResult
857
888
validateMap terms rule =
858
889
($ rule) <$> do
859
890
getRule rule >>= \ case
@@ -899,7 +930,10 @@ dummyRule = MRuleRef (Name "dummy" mempty)
899
930
-- | Validate both rules
900
931
ctrlAnd ::
901
932
Monad m =>
902
- (Rule -> m CDDLResult ) -> Rule -> Rule -> m (Rule -> CDDLResult )
933
+ (Rule -> m CDDLResult ) ->
934
+ Rule ->
935
+ Rule ->
936
+ m (Rule -> CDDLResult )
903
937
ctrlAnd v tgt ctrl =
904
938
v tgt >>= \ case
905
939
Valid _ ->
0 commit comments