Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change Number bounds from Int to Scientific. #18

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/Data/JSON/Schema/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ module Data.JSON.Schema.Types
import Data.Fixed
import Data.Maybe
import Data.Proxy
import Data.Scientific
import Data.String
import Data.Text (Text)
import Data.Time.Clock (UTCTime)
Expand Down Expand Up @@ -55,8 +56,8 @@ data Schema =

-- | A type for bounds on number domains. Use Nothing when no lower or upper bound makes sense
data Bound = Bound
{ lower :: Maybe Int
, upper :: Maybe Int
{ lower :: Maybe Scientific
, upper :: Maybe Scientific
} deriving (Eq, Show)

-- | A type for bounds on lengths for strings and arrays. Use Nothing when no lower or upper bound makes sense
Expand Down
4 changes: 2 additions & 2 deletions src/Data/JSON/Schema/Validate.hs
Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,13 @@ unique vs = do

inLower :: S.Bound -> Scientific -> M ()
inLower b v =
if (maybe True ((<= v) . fromIntegral) . S.lower $ b)
if (maybe True (<= v) . S.lower $ b)
then ok
else err (BoundError b v)

inUpper :: S.Bound -> Scientific -> M ()
inUpper b v =
if (maybe True ((>= v) . fromIntegral) . S.upper $ b)
if (maybe True (>= v) . S.upper $ b)
then ok
else err (BoundError b v)

Expand Down