{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.LexModels.Types.SlotTypeRegexConfiguration
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.LexModels.Types.SlotTypeRegexConfiguration where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Provides a regular expression used to validate the value of a slot.
--
-- /See:/ 'newSlotTypeRegexConfiguration' smart constructor.
data SlotTypeRegexConfiguration = SlotTypeRegexConfiguration'
  { -- | A regular expression used to validate the value of a slot.
    --
    -- Use a standard regular expression. Amazon Lex supports the following
    -- characters in the regular expression:
    --
    -- -   A-Z, a-z
    --
    -- -   0-9
    --
    -- -   Unicode characters (\"\\ u\<Unicode>\")
    --
    -- Represent Unicode characters with four digits, for example \"\\u0041\"
    -- or \"\\u005A\".
    --
    -- The following regular expression operators are not supported:
    --
    -- -   Infinite repeaters: *, +, or {x,} with no upper bound.
    --
    -- -   Wild card (.)
    SlotTypeRegexConfiguration -> Text
pattern' :: Prelude.Text
  }
  deriving (SlotTypeRegexConfiguration -> SlotTypeRegexConfiguration -> Bool
(SlotTypeRegexConfiguration -> SlotTypeRegexConfiguration -> Bool)
-> (SlotTypeRegexConfiguration
    -> SlotTypeRegexConfiguration -> Bool)
-> Eq SlotTypeRegexConfiguration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SlotTypeRegexConfiguration -> SlotTypeRegexConfiguration -> Bool
$c/= :: SlotTypeRegexConfiguration -> SlotTypeRegexConfiguration -> Bool
== :: SlotTypeRegexConfiguration -> SlotTypeRegexConfiguration -> Bool
$c== :: SlotTypeRegexConfiguration -> SlotTypeRegexConfiguration -> Bool
Prelude.Eq, ReadPrec [SlotTypeRegexConfiguration]
ReadPrec SlotTypeRegexConfiguration
Int -> ReadS SlotTypeRegexConfiguration
ReadS [SlotTypeRegexConfiguration]
(Int -> ReadS SlotTypeRegexConfiguration)
-> ReadS [SlotTypeRegexConfiguration]
-> ReadPrec SlotTypeRegexConfiguration
-> ReadPrec [SlotTypeRegexConfiguration]
-> Read SlotTypeRegexConfiguration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SlotTypeRegexConfiguration]
$creadListPrec :: ReadPrec [SlotTypeRegexConfiguration]
readPrec :: ReadPrec SlotTypeRegexConfiguration
$creadPrec :: ReadPrec SlotTypeRegexConfiguration
readList :: ReadS [SlotTypeRegexConfiguration]
$creadList :: ReadS [SlotTypeRegexConfiguration]
readsPrec :: Int -> ReadS SlotTypeRegexConfiguration
$creadsPrec :: Int -> ReadS SlotTypeRegexConfiguration
Prelude.Read, Int -> SlotTypeRegexConfiguration -> ShowS
[SlotTypeRegexConfiguration] -> ShowS
SlotTypeRegexConfiguration -> String
(Int -> SlotTypeRegexConfiguration -> ShowS)
-> (SlotTypeRegexConfiguration -> String)
-> ([SlotTypeRegexConfiguration] -> ShowS)
-> Show SlotTypeRegexConfiguration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SlotTypeRegexConfiguration] -> ShowS
$cshowList :: [SlotTypeRegexConfiguration] -> ShowS
show :: SlotTypeRegexConfiguration -> String
$cshow :: SlotTypeRegexConfiguration -> String
showsPrec :: Int -> SlotTypeRegexConfiguration -> ShowS
$cshowsPrec :: Int -> SlotTypeRegexConfiguration -> ShowS
Prelude.Show, (forall x.
 SlotTypeRegexConfiguration -> Rep SlotTypeRegexConfiguration x)
-> (forall x.
    Rep SlotTypeRegexConfiguration x -> SlotTypeRegexConfiguration)
-> Generic SlotTypeRegexConfiguration
forall x.
Rep SlotTypeRegexConfiguration x -> SlotTypeRegexConfiguration
forall x.
SlotTypeRegexConfiguration -> Rep SlotTypeRegexConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep SlotTypeRegexConfiguration x -> SlotTypeRegexConfiguration
$cfrom :: forall x.
SlotTypeRegexConfiguration -> Rep SlotTypeRegexConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'SlotTypeRegexConfiguration' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'pattern'', 'slotTypeRegexConfiguration_pattern' - A regular expression used to validate the value of a slot.
--
-- Use a standard regular expression. Amazon Lex supports the following
-- characters in the regular expression:
--
-- -   A-Z, a-z
--
-- -   0-9
--
-- -   Unicode characters (\"\\ u\<Unicode>\")
--
-- Represent Unicode characters with four digits, for example \"\\u0041\"
-- or \"\\u005A\".
--
-- The following regular expression operators are not supported:
--
-- -   Infinite repeaters: *, +, or {x,} with no upper bound.
--
-- -   Wild card (.)
newSlotTypeRegexConfiguration ::
  -- | 'pattern''
  Prelude.Text ->
  SlotTypeRegexConfiguration
newSlotTypeRegexConfiguration :: Text -> SlotTypeRegexConfiguration
newSlotTypeRegexConfiguration Text
pPattern_ =
  SlotTypeRegexConfiguration' :: Text -> SlotTypeRegexConfiguration
SlotTypeRegexConfiguration' {$sel:pattern':SlotTypeRegexConfiguration' :: Text
pattern' = Text
pPattern_}

-- | A regular expression used to validate the value of a slot.
--
-- Use a standard regular expression. Amazon Lex supports the following
-- characters in the regular expression:
--
-- -   A-Z, a-z
--
-- -   0-9
--
-- -   Unicode characters (\"\\ u\<Unicode>\")
--
-- Represent Unicode characters with four digits, for example \"\\u0041\"
-- or \"\\u005A\".
--
-- The following regular expression operators are not supported:
--
-- -   Infinite repeaters: *, +, or {x,} with no upper bound.
--
-- -   Wild card (.)
slotTypeRegexConfiguration_pattern :: Lens.Lens' SlotTypeRegexConfiguration Prelude.Text
slotTypeRegexConfiguration_pattern :: (Text -> f Text)
-> SlotTypeRegexConfiguration -> f SlotTypeRegexConfiguration
slotTypeRegexConfiguration_pattern = (SlotTypeRegexConfiguration -> Text)
-> (SlotTypeRegexConfiguration
    -> Text -> SlotTypeRegexConfiguration)
-> Lens
     SlotTypeRegexConfiguration SlotTypeRegexConfiguration Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SlotTypeRegexConfiguration' {Text
pattern' :: Text
$sel:pattern':SlotTypeRegexConfiguration' :: SlotTypeRegexConfiguration -> Text
pattern'} -> Text
pattern') (\s :: SlotTypeRegexConfiguration
s@SlotTypeRegexConfiguration' {} Text
a -> SlotTypeRegexConfiguration
s {$sel:pattern':SlotTypeRegexConfiguration' :: Text
pattern' = Text
a} :: SlotTypeRegexConfiguration)

instance Core.FromJSON SlotTypeRegexConfiguration where
  parseJSON :: Value -> Parser SlotTypeRegexConfiguration
parseJSON =
    String
-> (Object -> Parser SlotTypeRegexConfiguration)
-> Value
-> Parser SlotTypeRegexConfiguration
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"SlotTypeRegexConfiguration"
      ( \Object
x ->
          Text -> SlotTypeRegexConfiguration
SlotTypeRegexConfiguration'
            (Text -> SlotTypeRegexConfiguration)
-> Parser Text -> Parser SlotTypeRegexConfiguration
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"pattern")
      )

instance Prelude.Hashable SlotTypeRegexConfiguration

instance Prelude.NFData SlotTypeRegexConfiguration

instance Core.ToJSON SlotTypeRegexConfiguration where
  toJSON :: SlotTypeRegexConfiguration -> Value
toJSON SlotTypeRegexConfiguration' {Text
pattern' :: Text
$sel:pattern':SlotTypeRegexConfiguration' :: SlotTypeRegexConfiguration -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"pattern" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
pattern')]
      )