{-# 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.CognitoIdentityProvider.Types.NumberAttributeConstraintsType
-- 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.CognitoIdentityProvider.Types.NumberAttributeConstraintsType where

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

-- | The minimum and maximum value of an attribute that is of the number data
-- type.
--
-- /See:/ 'newNumberAttributeConstraintsType' smart constructor.
data NumberAttributeConstraintsType = NumberAttributeConstraintsType'
  { -- | The maximum value of an attribute that is of the number data type.
    NumberAttributeConstraintsType -> Maybe Text
maxValue :: Prelude.Maybe Prelude.Text,
    -- | The minimum value of an attribute that is of the number data type.
    NumberAttributeConstraintsType -> Maybe Text
minValue :: Prelude.Maybe Prelude.Text
  }
  deriving (NumberAttributeConstraintsType
-> NumberAttributeConstraintsType -> Bool
(NumberAttributeConstraintsType
 -> NumberAttributeConstraintsType -> Bool)
-> (NumberAttributeConstraintsType
    -> NumberAttributeConstraintsType -> Bool)
-> Eq NumberAttributeConstraintsType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: NumberAttributeConstraintsType
-> NumberAttributeConstraintsType -> Bool
$c/= :: NumberAttributeConstraintsType
-> NumberAttributeConstraintsType -> Bool
== :: NumberAttributeConstraintsType
-> NumberAttributeConstraintsType -> Bool
$c== :: NumberAttributeConstraintsType
-> NumberAttributeConstraintsType -> Bool
Prelude.Eq, ReadPrec [NumberAttributeConstraintsType]
ReadPrec NumberAttributeConstraintsType
Int -> ReadS NumberAttributeConstraintsType
ReadS [NumberAttributeConstraintsType]
(Int -> ReadS NumberAttributeConstraintsType)
-> ReadS [NumberAttributeConstraintsType]
-> ReadPrec NumberAttributeConstraintsType
-> ReadPrec [NumberAttributeConstraintsType]
-> Read NumberAttributeConstraintsType
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [NumberAttributeConstraintsType]
$creadListPrec :: ReadPrec [NumberAttributeConstraintsType]
readPrec :: ReadPrec NumberAttributeConstraintsType
$creadPrec :: ReadPrec NumberAttributeConstraintsType
readList :: ReadS [NumberAttributeConstraintsType]
$creadList :: ReadS [NumberAttributeConstraintsType]
readsPrec :: Int -> ReadS NumberAttributeConstraintsType
$creadsPrec :: Int -> ReadS NumberAttributeConstraintsType
Prelude.Read, Int -> NumberAttributeConstraintsType -> ShowS
[NumberAttributeConstraintsType] -> ShowS
NumberAttributeConstraintsType -> String
(Int -> NumberAttributeConstraintsType -> ShowS)
-> (NumberAttributeConstraintsType -> String)
-> ([NumberAttributeConstraintsType] -> ShowS)
-> Show NumberAttributeConstraintsType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [NumberAttributeConstraintsType] -> ShowS
$cshowList :: [NumberAttributeConstraintsType] -> ShowS
show :: NumberAttributeConstraintsType -> String
$cshow :: NumberAttributeConstraintsType -> String
showsPrec :: Int -> NumberAttributeConstraintsType -> ShowS
$cshowsPrec :: Int -> NumberAttributeConstraintsType -> ShowS
Prelude.Show, (forall x.
 NumberAttributeConstraintsType
 -> Rep NumberAttributeConstraintsType x)
-> (forall x.
    Rep NumberAttributeConstraintsType x
    -> NumberAttributeConstraintsType)
-> Generic NumberAttributeConstraintsType
forall x.
Rep NumberAttributeConstraintsType x
-> NumberAttributeConstraintsType
forall x.
NumberAttributeConstraintsType
-> Rep NumberAttributeConstraintsType x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep NumberAttributeConstraintsType x
-> NumberAttributeConstraintsType
$cfrom :: forall x.
NumberAttributeConstraintsType
-> Rep NumberAttributeConstraintsType x
Prelude.Generic)

-- |
-- Create a value of 'NumberAttributeConstraintsType' 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:
--
-- 'maxValue', 'numberAttributeConstraintsType_maxValue' - The maximum value of an attribute that is of the number data type.
--
-- 'minValue', 'numberAttributeConstraintsType_minValue' - The minimum value of an attribute that is of the number data type.
newNumberAttributeConstraintsType ::
  NumberAttributeConstraintsType
newNumberAttributeConstraintsType :: NumberAttributeConstraintsType
newNumberAttributeConstraintsType =
  NumberAttributeConstraintsType' :: Maybe Text -> Maybe Text -> NumberAttributeConstraintsType
NumberAttributeConstraintsType'
    { $sel:maxValue:NumberAttributeConstraintsType' :: Maybe Text
maxValue =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:minValue:NumberAttributeConstraintsType' :: Maybe Text
minValue = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The maximum value of an attribute that is of the number data type.
numberAttributeConstraintsType_maxValue :: Lens.Lens' NumberAttributeConstraintsType (Prelude.Maybe Prelude.Text)
numberAttributeConstraintsType_maxValue :: (Maybe Text -> f (Maybe Text))
-> NumberAttributeConstraintsType
-> f NumberAttributeConstraintsType
numberAttributeConstraintsType_maxValue = (NumberAttributeConstraintsType -> Maybe Text)
-> (NumberAttributeConstraintsType
    -> Maybe Text -> NumberAttributeConstraintsType)
-> Lens
     NumberAttributeConstraintsType
     NumberAttributeConstraintsType
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NumberAttributeConstraintsType' {Maybe Text
maxValue :: Maybe Text
$sel:maxValue:NumberAttributeConstraintsType' :: NumberAttributeConstraintsType -> Maybe Text
maxValue} -> Maybe Text
maxValue) (\s :: NumberAttributeConstraintsType
s@NumberAttributeConstraintsType' {} Maybe Text
a -> NumberAttributeConstraintsType
s {$sel:maxValue:NumberAttributeConstraintsType' :: Maybe Text
maxValue = Maybe Text
a} :: NumberAttributeConstraintsType)

-- | The minimum value of an attribute that is of the number data type.
numberAttributeConstraintsType_minValue :: Lens.Lens' NumberAttributeConstraintsType (Prelude.Maybe Prelude.Text)
numberAttributeConstraintsType_minValue :: (Maybe Text -> f (Maybe Text))
-> NumberAttributeConstraintsType
-> f NumberAttributeConstraintsType
numberAttributeConstraintsType_minValue = (NumberAttributeConstraintsType -> Maybe Text)
-> (NumberAttributeConstraintsType
    -> Maybe Text -> NumberAttributeConstraintsType)
-> Lens
     NumberAttributeConstraintsType
     NumberAttributeConstraintsType
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NumberAttributeConstraintsType' {Maybe Text
minValue :: Maybe Text
$sel:minValue:NumberAttributeConstraintsType' :: NumberAttributeConstraintsType -> Maybe Text
minValue} -> Maybe Text
minValue) (\s :: NumberAttributeConstraintsType
s@NumberAttributeConstraintsType' {} Maybe Text
a -> NumberAttributeConstraintsType
s {$sel:minValue:NumberAttributeConstraintsType' :: Maybe Text
minValue = Maybe Text
a} :: NumberAttributeConstraintsType)

instance Core.FromJSON NumberAttributeConstraintsType where
  parseJSON :: Value -> Parser NumberAttributeConstraintsType
parseJSON =
    String
-> (Object -> Parser NumberAttributeConstraintsType)
-> Value
-> Parser NumberAttributeConstraintsType
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"NumberAttributeConstraintsType"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> NumberAttributeConstraintsType
NumberAttributeConstraintsType'
            (Maybe Text -> Maybe Text -> NumberAttributeConstraintsType)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> NumberAttributeConstraintsType)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"MaxValue")
            Parser (Maybe Text -> NumberAttributeConstraintsType)
-> Parser (Maybe Text) -> Parser NumberAttributeConstraintsType
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"MinValue")
      )

instance
  Prelude.Hashable
    NumberAttributeConstraintsType

instance
  Prelude.NFData
    NumberAttributeConstraintsType

instance Core.ToJSON NumberAttributeConstraintsType where
  toJSON :: NumberAttributeConstraintsType -> Value
toJSON NumberAttributeConstraintsType' {Maybe Text
minValue :: Maybe Text
maxValue :: Maybe Text
$sel:minValue:NumberAttributeConstraintsType' :: NumberAttributeConstraintsType -> Maybe Text
$sel:maxValue:NumberAttributeConstraintsType' :: NumberAttributeConstraintsType -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"MaxValue" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
maxValue,
            (Text
"MinValue" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
minValue
          ]
      )