35 lines
1.1 KiB
Haskell
35 lines
1.1 KiB
Haskell
let Prelude =
|
|
{- this will have to get bumped when prelude is updated -}
|
|
./prelude.dhall
|
|
sha256:a6036bc38d883450598d1de7c98ead113196fe2db02e9733855668b18096f07b
|
|
|
|
let Schema =
|
|
./schema.dhall
|
|
sha256:3f615a66aa32fc6c61a7ecfa42b809efcd42acbccf55ed7b0067bd11636debb2
|
|
? ./schema.dhall
|
|
|
|
let Schema/validate
|
|
: Schema.Type -> Type
|
|
=
|
|
-- | define validation.
|
|
\(c : Schema.Type) ->
|
|
let expected = { validPort = True, validSMTPPort = True }
|
|
|
|
let actual =
|
|
{ validPort =
|
|
-- | make sure port number belongs to the <1;65535> range.
|
|
Prelude.Natural.lessThanEqual 1 c.Port
|
|
&& Prelude.Natural.lessThanEqual c.Port 65535
|
|
, validSMTPPort =
|
|
if c.Mailer.Enabled == False
|
|
then True
|
|
else Prelude.Natural.lessThanEqual 1 c.Mailer.SMTPPort
|
|
&& Prelude.Natural.lessThanEqual
|
|
c.Mailer.SMTPPort
|
|
65535
|
|
}
|
|
|
|
in expected === actual
|
|
|
|
in Schema/validate
|