schema,validation: add mailer record+defaults

This commit is contained in:
leo 2023-05-17 13:16:54 +02:00
parent b61e07b57c
commit 2eef5a1328
Signed by: wanderer
SSH Key Fingerprint: SHA256:Dp8+iwKHSlrMEHzE3bJnPng70I7LEsa3IJXRH/U+idQ
3 changed files with 35 additions and 4 deletions

@ -1,10 +1,10 @@
{ Schema = { Schema =
./schema.dhall ./schema.dhall
sha256:99dc461563042c4c4df92a8ce5a66842496be9fb2303bd0d7bf344417888cf61 sha256:1aa8c2f42fc6fc3055a35c1285314340f934aa50226c6cdc96f8d19471a84835
? ./schema.dhall ? ./schema.dhall
, Schema/validate = , Schema/validate =
./validate.dhall ./validate.dhall
sha256:03d846ce0f42478c630708dd45cb9883f74f6ad97d4c0325bd6f6879368c7bd1 sha256:78f05c1c7d49d3d8854b8a000600a30e55c7c2771bf9f91dc4717ef30a191a91
? ./validate.dhall ? ./validate.dhall
, Schema/version = , Schema/version =
./version.dhall ./version.dhall

@ -15,6 +15,21 @@ let Schema =
, Gzip : Natural , Gzip : Natural
, Timeout : Natural , Timeout : Natural
} }
, Mailer :
{ Enabled : Bool
, Protocol : Text
, SMTPAddr : Text
, SMTPPort : Natural
, ForceTrustServerCert : Bool
, EnableHELO : Bool
, HELOHostname : Text
, Auth : Text
, From : Text
, User : Text
, Password : Text
, SubjectPrefix : Text
, SendPlainText : Bool
}
, AppName : Text , AppName : Text
, LiveMode : Bool , LiveMode : Bool
, DevelMode : Bool , DevelMode : Bool
@ -44,6 +59,15 @@ let Schema =
, Gzip = 0 , Gzip = 0
, Timeout = 0 , Timeout = 0
} }
, Mailer =
{ Enabled = False
, Protocol = "smtps"
, SMTPPort = 465
, ForceTrustServerCert = False
, EnableHELO = False
, SubjectPrefix = "pcmt - "
, SendPlainText = True
}
, AppName = "pcmt" , AppName = "pcmt"
, LiveMode = False , LiveMode = False
, DevelMode = False , DevelMode = False

@ -5,7 +5,7 @@ let Prelude =
let Schema = let Schema =
./schema.dhall ./schema.dhall
sha256:99dc461563042c4c4df92a8ce5a66842496be9fb2303bd0d7bf344417888cf61 sha256:1aa8c2f42fc6fc3055a35c1285314340f934aa50226c6cdc96f8d19471a84835
? ./schema.dhall ? ./schema.dhall
let Schema/validate let Schema/validate
@ -13,13 +13,20 @@ let Schema/validate
= =
-- | define validation. -- | define validation.
\(c : Schema.Type) -> \(c : Schema.Type) ->
let expected = { validPort = True } let expected = { validPort = True, validSMTPPort = True }
let actual = let actual =
{ validPort = { validPort =
-- | make sure port number belongs to the <1;65535> range. -- | make sure port number belongs to the <1;65535> range.
Prelude.Natural.lessThanEqual 1 c.Port Prelude.Natural.lessThanEqual 1 c.Port
&& Prelude.Natural.lessThanEqual c.Port 65535 && 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 expected === actual