{-# 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.DataPipeline.Types.ValidationError
-- 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.DataPipeline.Types.ValidationError where

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

-- | Defines a validation error. Validation errors prevent pipeline
-- activation. The set of validation errors that can be returned are
-- defined by AWS Data Pipeline.
--
-- /See:/ 'newValidationError' smart constructor.
data ValidationError = ValidationError'
  { -- | The identifier of the object that contains the validation error.
    ValidationError -> Maybe Text
id :: Prelude.Maybe Prelude.Text,
    -- | A description of the validation error.
    ValidationError -> Maybe [Text]
errors :: Prelude.Maybe [Prelude.Text]
  }
  deriving (ValidationError -> ValidationError -> Bool
(ValidationError -> ValidationError -> Bool)
-> (ValidationError -> ValidationError -> Bool)
-> Eq ValidationError
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ValidationError -> ValidationError -> Bool
$c/= :: ValidationError -> ValidationError -> Bool
== :: ValidationError -> ValidationError -> Bool
$c== :: ValidationError -> ValidationError -> Bool
Prelude.Eq, ReadPrec [ValidationError]
ReadPrec ValidationError
Int -> ReadS ValidationError
ReadS [ValidationError]
(Int -> ReadS ValidationError)
-> ReadS [ValidationError]
-> ReadPrec ValidationError
-> ReadPrec [ValidationError]
-> Read ValidationError
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ValidationError]
$creadListPrec :: ReadPrec [ValidationError]
readPrec :: ReadPrec ValidationError
$creadPrec :: ReadPrec ValidationError
readList :: ReadS [ValidationError]
$creadList :: ReadS [ValidationError]
readsPrec :: Int -> ReadS ValidationError
$creadsPrec :: Int -> ReadS ValidationError
Prelude.Read, Int -> ValidationError -> ShowS
[ValidationError] -> ShowS
ValidationError -> String
(Int -> ValidationError -> ShowS)
-> (ValidationError -> String)
-> ([ValidationError] -> ShowS)
-> Show ValidationError
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ValidationError] -> ShowS
$cshowList :: [ValidationError] -> ShowS
show :: ValidationError -> String
$cshow :: ValidationError -> String
showsPrec :: Int -> ValidationError -> ShowS
$cshowsPrec :: Int -> ValidationError -> ShowS
Prelude.Show, (forall x. ValidationError -> Rep ValidationError x)
-> (forall x. Rep ValidationError x -> ValidationError)
-> Generic ValidationError
forall x. Rep ValidationError x -> ValidationError
forall x. ValidationError -> Rep ValidationError x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ValidationError x -> ValidationError
$cfrom :: forall x. ValidationError -> Rep ValidationError x
Prelude.Generic)

-- |
-- Create a value of 'ValidationError' 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:
--
-- 'id', 'validationError_id' - The identifier of the object that contains the validation error.
--
-- 'errors', 'validationError_errors' - A description of the validation error.
newValidationError ::
  ValidationError
newValidationError :: ValidationError
newValidationError =
  ValidationError' :: Maybe Text -> Maybe [Text] -> ValidationError
ValidationError'
    { $sel:id:ValidationError' :: Maybe Text
id = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:errors:ValidationError' :: Maybe [Text]
errors = Maybe [Text]
forall a. Maybe a
Prelude.Nothing
    }

-- | The identifier of the object that contains the validation error.
validationError_id :: Lens.Lens' ValidationError (Prelude.Maybe Prelude.Text)
validationError_id :: (Maybe Text -> f (Maybe Text))
-> ValidationError -> f ValidationError
validationError_id = (ValidationError -> Maybe Text)
-> (ValidationError -> Maybe Text -> ValidationError)
-> Lens ValidationError ValidationError (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ValidationError' {Maybe Text
id :: Maybe Text
$sel:id:ValidationError' :: ValidationError -> Maybe Text
id} -> Maybe Text
id) (\s :: ValidationError
s@ValidationError' {} Maybe Text
a -> ValidationError
s {$sel:id:ValidationError' :: Maybe Text
id = Maybe Text
a} :: ValidationError)

-- | A description of the validation error.
validationError_errors :: Lens.Lens' ValidationError (Prelude.Maybe [Prelude.Text])
validationError_errors :: (Maybe [Text] -> f (Maybe [Text]))
-> ValidationError -> f ValidationError
validationError_errors = (ValidationError -> Maybe [Text])
-> (ValidationError -> Maybe [Text] -> ValidationError)
-> Lens
     ValidationError ValidationError (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ValidationError' {Maybe [Text]
errors :: Maybe [Text]
$sel:errors:ValidationError' :: ValidationError -> Maybe [Text]
errors} -> Maybe [Text]
errors) (\s :: ValidationError
s@ValidationError' {} Maybe [Text]
a -> ValidationError
s {$sel:errors:ValidationError' :: Maybe [Text]
errors = Maybe [Text]
a} :: ValidationError) ((Maybe [Text] -> f (Maybe [Text]))
 -> ValidationError -> f ValidationError)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> ValidationError
-> f ValidationError
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON ValidationError where
  parseJSON :: Value -> Parser ValidationError
parseJSON =
    String
-> (Object -> Parser ValidationError)
-> Value
-> Parser ValidationError
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ValidationError"
      ( \Object
x ->
          Maybe Text -> Maybe [Text] -> ValidationError
ValidationError'
            (Maybe Text -> Maybe [Text] -> ValidationError)
-> Parser (Maybe Text) -> Parser (Maybe [Text] -> ValidationError)
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
"id")
            Parser (Maybe [Text] -> ValidationError)
-> Parser (Maybe [Text]) -> Parser ValidationError
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe [Text]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"errors" Parser (Maybe (Maybe [Text]))
-> Maybe [Text] -> Parser (Maybe [Text])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Text]
forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable ValidationError

instance Prelude.NFData ValidationError