module Cachix.Types.NarInfoCreate
( NarInfoCreate (..),
NarInfoInvalid,
isNarInfoCreateValid,
)
where
import Data.Aeson
( FromJSON,
ToJSON,
)
import Data.Swagger
import Protolude
data NarInfoCreate
= NarInfoCreate
{
cStoreHash :: Text,
cStoreSuffix :: Text,
cNarHash :: Text,
cNarSize :: Integer,
cFileHash :: Text,
cFileSize :: Integer,
cReferences :: [Text],
cDeriver :: Text,
cSig :: Text
}
deriving (Generic, Show, FromJSON, ToJSON, ToSchema)
data NarInfoInvalid
= NarSizeIsZero
deriving (Show, Exception)
isNarInfoCreateValid :: NarInfoCreate -> Either NarInfoInvalid ()
isNarInfoCreateValid nic
| cNarSize nic == 0 = Left NarSizeIsZero
| otherwise = Right ()