This repository was archived by the owner on May 2, 2020. It is now read-only.
File tree 4 files changed +63
-4
lines changed
src/JSONSchema/Validator/Draft4
JSONSchema/Validator/Draft4
4 files changed +63
-4
lines changed Original file line number Diff line number Diff line change @@ -81,6 +81,51 @@ library
81
81
, text >= 1.1
82
82
, vector >= 0.10
83
83
84
+ test-suite spec
85
+ hs-source-dirs :
86
+ test
87
+ src
88
+ main-is : Spec.hs
89
+ type : exitcode-stdio-1.0
90
+ default-language : Haskell2010
91
+ ghc-options :
92
+ -Wall
93
+ default-extensions :
94
+ DeriveGeneric
95
+ NoImplicitPrelude
96
+ OverloadedStrings
97
+ ScopedTypeVariables
98
+ other-modules :
99
+ Import
100
+ JSONSchema.Validator.Draft4.String
101
+
102
+ JSONSchema.Validator.Draft4.StringSpec
103
+ build-depends :
104
+ base >= 4.7 && < 5
105
+ -- 0.11 is for `.:!`:
106
+ , aeson >= 0.11
107
+ , bytestring >= 0.10
108
+ , containers >= 0.5
109
+ , file-embed >= 0.0.8
110
+ , filepath >= 1.3
111
+ , hashable >= 1.2
112
+ , hjsonpointer >= 1.1
113
+ -- 0.4.30 is for parseUrlThrow:
114
+ , http-client >= 0.4.30
115
+ , http-client-tls >= 0.3
116
+ , http-types >= 0.8
117
+ , pcre-heavy >= 1.0
118
+ , profunctors >= 5.0
119
+ , protolude >= 0.1.10
120
+ , QuickCheck >= 2.8
121
+ , safe-exceptions >= 0.1.6
122
+ , scientific >= 0.3
123
+ , unordered-containers >= 0.2
124
+ , text >= 1.1
125
+ , vector >= 0.10
126
+
127
+ , hspec >= 2.2
128
+
84
129
test-suite local
85
130
hs-source-dirs :
86
131
test
Original file line number Diff line number Diff line change @@ -22,10 +22,8 @@ data MaxLengthInvalid
22
22
= MaxLengthInvalid MaxLength Text
23
23
deriving (Eq , Show )
24
24
25
- -- | The spec requires @"maxLength"@ to be non-negative.
26
25
maxLengthVal :: MaxLength -> Text -> Maybe MaxLengthInvalid
27
26
maxLengthVal a@ (MaxLength n) x
28
- | n <= 0 = Nothing
29
27
| T. length x > n = Just (MaxLengthInvalid a x)
30
28
| otherwise = Nothing
31
29
@@ -45,10 +43,8 @@ data MinLengthInvalid
45
43
= MinLengthInvalid MinLength Text
46
44
deriving (Eq , Show )
47
45
48
- -- | The spec requires @"minLength"@ to be non-negative.
49
46
minLengthVal :: MinLength -> Text -> Maybe MinLengthInvalid
50
47
minLengthVal a@ (MinLength n) x
51
- | n <= 0 = Nothing
52
48
| T. length x < n = Just (MinLengthInvalid a x)
53
49
| otherwise = Nothing
54
50
Original file line number Diff line number Diff line change
1
+ module JSONSchema.Validator.Draft4.StringSpec (spec ) where
2
+
3
+ import Protolude
4
+
5
+ import Test.Hspec
6
+
7
+ import JSONSchema.Validator.Draft4.String
8
+
9
+ spec :: Spec
10
+ spec = do
11
+ describe " maxLengthVal" $ do
12
+ context " with 0" $ do
13
+ it " accepts the empty string" $ do
14
+ maxLengthVal (MaxLength 0 ) " " `shouldBe` Nothing
15
+
16
+ it " rejects other strings" $ do
17
+ maxLengthVal (MaxLength 0 ) " foo" `shouldBe` Just (MaxLengthInvalid (MaxLength 0 ) " foo" )
Original file line number Diff line number Diff line change
1
+ {-# OPTIONS_GHC -fforce-recomp -F -pgmF hspec-discover #-}
You can’t perform that action at this time.
0 commit comments