{-# 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.LexV2Models.Types.SlotValueRegexFilter
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.LexV2Models.Types.SlotValueRegexFilter where

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

-- | Provides a regular expression used to validate the value of a slot.
--
-- /See:/ 'newSlotValueRegexFilter' smart constructor.
data SlotValueRegexFilter = SlotValueRegexFilter'
  { -- | 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 (.)
    SlotValueRegexFilter -> Text
pattern' :: Prelude.Text
  }
  deriving (SlotValueRegexFilter -> SlotValueRegexFilter -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SlotValueRegexFilter -> SlotValueRegexFilter -> Bool
$c/= :: SlotValueRegexFilter -> SlotValueRegexFilter -> Bool
== :: SlotValueRegexFilter -> SlotValueRegexFilter -> Bool
$c== :: SlotValueRegexFilter -> SlotValueRegexFilter -> Bool
Prelude.Eq, ReadPrec [SlotValueRegexFilter]
ReadPrec SlotValueRegexFilter
Int -> ReadS SlotValueRegexFilter
ReadS [SlotValueRegexFilter]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SlotValueRegexFilter]
$creadListPrec :: ReadPrec [SlotValueRegexFilter]
readPrec :: ReadPrec SlotValueRegexFilter
$creadPrec :: ReadPrec SlotValueRegexFilter
readList :: ReadS [SlotValueRegexFilter]
$creadList :: ReadS [SlotValueRegexFilter]
readsPrec :: Int -> ReadS SlotValueRegexFilter
$creadsPrec :: Int -> ReadS SlotValueRegexFilter
Prelude.Read, Int -> SlotValueRegexFilter -> ShowS
[SlotValueRegexFilter] -> ShowS
SlotValueRegexFilter -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SlotValueRegexFilter] -> ShowS
$cshowList :: [SlotValueRegexFilter] -> ShowS
show :: SlotValueRegexFilter -> String
$cshow :: SlotValueRegexFilter -> String
showsPrec :: Int -> SlotValueRegexFilter -> ShowS
$cshowsPrec :: Int -> SlotValueRegexFilter -> ShowS
Prelude.Show, forall x. Rep SlotValueRegexFilter x -> SlotValueRegexFilter
forall x. SlotValueRegexFilter -> Rep SlotValueRegexFilter x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SlotValueRegexFilter x -> SlotValueRegexFilter
$cfrom :: forall x. SlotValueRegexFilter -> Rep SlotValueRegexFilter x
Prelude.Generic)

-- |
-- Create a value of 'SlotValueRegexFilter' 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'', 'slotValueRegexFilter_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 (.)
newSlotValueRegexFilter ::
  -- | 'pattern''
  Prelude.Text ->
  SlotValueRegexFilter
newSlotValueRegexFilter :: Text -> SlotValueRegexFilter
newSlotValueRegexFilter Text
pPattern_ =
  SlotValueRegexFilter' {$sel:pattern':SlotValueRegexFilter' :: 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 (.)
slotValueRegexFilter_pattern :: Lens.Lens' SlotValueRegexFilter Prelude.Text
slotValueRegexFilter_pattern :: Lens' SlotValueRegexFilter Text
slotValueRegexFilter_pattern = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SlotValueRegexFilter' {Text
pattern' :: Text
$sel:pattern':SlotValueRegexFilter' :: SlotValueRegexFilter -> Text
pattern'} -> Text
pattern') (\s :: SlotValueRegexFilter
s@SlotValueRegexFilter' {} Text
a -> SlotValueRegexFilter
s {$sel:pattern':SlotValueRegexFilter' :: Text
pattern' = Text
a} :: SlotValueRegexFilter)

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

instance Prelude.Hashable SlotValueRegexFilter where
  hashWithSalt :: Int -> SlotValueRegexFilter -> Int
hashWithSalt Int
_salt SlotValueRegexFilter' {Text
pattern' :: Text
$sel:pattern':SlotValueRegexFilter' :: SlotValueRegexFilter -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
pattern'

instance Prelude.NFData SlotValueRegexFilter where
  rnf :: SlotValueRegexFilter -> ()
rnf SlotValueRegexFilter' {Text
pattern' :: Text
$sel:pattern':SlotValueRegexFilter' :: SlotValueRegexFilter -> Text
..} = forall a. NFData a => a -> ()
Prelude.rnf Text
pattern'

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