h$K[I      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEF Safe-InferredOGHIJKLMNSafeuOSafe38 validaLike P8, but accumulates failures upon applicative composition.valida.Represents a validation failure with an error.valida)This behaves similar to the P" semigroup. i.e Returns the first . But also accumulates s.ExamplesSuccess 1 <> Success 2 Success 1Failure "error" <> Success 1 Success 1Success 2 <> Failure "error" Success 2$Failure ["err1"] <> Failure ["err2"]Failure ["err1","err2"][valida pureV is a  value.(<*>)\ behaves similar to P/, but accumulates failures instead of stopping.Examplespure 2 :: Validation String Int Success 2Success (+1) <*> Success 4 Success 5 Success (+1) <*> Failure "error"Failure "error"%Failure ["err1"] <*> Failure ["err2"]Failure ["err1","err2"]]valida fmap^ maps given function over a  value, does nothing on  value.Examplesfmap (+1) (Success 2) Success 3fmap (+1) (Failure "error")Failure "error"Safe8valida,The rule a Validator uses to run validation.?Contains a function that accepts the target type and returns a  result. The type- $ValidationRule (NonEmpty String) Int5, designates a rule that verifies the validity of an Int, and uses a value of type NonEmpty String( to represent error, in case of failure._validaThe validation predicate.valida'Low level function to manually build a ). You should use the combinators instead.ExamplesrunValidator (validate (vrule (\x -> if isDigit x then Success () else Failure "NotDigit"))) 'a'Failure "NotDigit"runValidator (validate (vrule (\x -> if isDigit x then Success () else Failure "NotDigit"))) '5' Success '5'`valida memptyY is a  that always succeeds.Examples"runValidator (validate mempty) 'a' Success 'a'avalida (<>)b creates a new  that only succeeds when both given rule succeed. Otherwise left-most failure is returned.ExamplesrunValidator (validate (failureIf even "IsEven" <> failureIf (>9) "GreaterThan9")) 5 Success 5runValidator (validate (failureIf even "IsEven" <> failureIf (>9) "GreaterThan9")) 4Failure ("IsEven" :| [])runValidator (validate (failureIf even "IsEven" <> failureIf (>9) "GreaterThan9")) 15Failure ("GreaterThan9" :| [])runValidator (validate (failureIf even "IsEven" <> failureIf (>9) "GreaterThan9")) 12Failure ("IsEven" :| [])_5Combinators and utilities for building and combining s.(c) TotallyNotChase, 2021MITtotallynotchase42@gmail.comStablePortableSafe/-validaBuild a rule that fails with given error if the given predicate succeeds. failureIf predc =  (c . predc)Examples5runValidator (validate (failureIf (>0) "Positive")) 5Failure ("Positive" :| [])5runValidator (validate (failureIf (>0) "Positive")) 0 Success 08runValidator (validate (failureIf (>0) "Positive")) (-1) Success (-1)validaBuild a rule that fails with given error #unless the given predicate succeeds. failureUnless predc =  (c . predc)Examples0) "NonPositive")) 5 Success 50) "NonPositive")) 0Failure ("NonPositive" :| [])?runValidator (validate (failureUnless (>0) "NonPositive")) (-1)Failure ("NonPositive" :| []) validaLike  but uses Unit as the  error type. failureIf' predc =   (c . predc) label (R# (err :| [])) (failureIf' predc) =  predc errExamples+runValidator (validate (failureIf' (>0))) 5 Failure ()+runValidator (validate (failureIf' (>0))) 0 Success 0.runValidator (validate (failureIf' (>0))) (-1) Success (-1) validaLike  but uses Unit as the  error type. failureUnless' predc =   (c . predc) label (R' (err :| [])) (failureUnless' predc) =  predc errExamples/runValidator (validate (failureUnless' (>0))) 5 Success 5/runValidator (validate (failureUnless' (>0))) 0 Failure ()2runValidator (validate (failureUnless' (>0))) (-1) Failure () valida!Build an equality rule for value.  mustBe x =  (==x) valida"Build an equality rule for length.  ofLength x =  ((==x) . d) valida(Build a minimum length (inclusive) rule. minLengthOf x =  ((>=n) . d)valida(Build a maximum length (inclusive) rule. maxLengthOf n =  ((<=n) . d)valida(Build a minimum length (inclusive) rule. lengthAbove x =   (x + 1) lengthAbove x =  ((>n) . d)valida(Build a maximum length (inclusive) rule. lengthBelow x =  (x - 1) lengthBelow x =  ((=x)valida'Build a maximum value (inclusive) rule. maxValueOf x =  (<=x)valida'Build a minimum value (exclusive) rule. valueAbove x =  (x + 1) valueAbove x =  (>x)valida'Build a maximum value (exclusive) rule. valueBelow x =  (x - 1) valueBelow x =  ( m <= x && x <= n)valida Build an g rule. onlyContains x =  (g x)valida Build an h rule. atleastContains x =  (h x)valida Build an i rule. mustContain x =  (==x) mustContain x =  (i x)validaLike   but uses Unit as the  error type.validaLike   but uses Unit as the  error type.validaLike   but uses Unit as the  error type.validaLike  but uses Unit as the  error type.validaLike  but uses Unit as the  error type. validaLike  but uses Unit as the  error type.!validaLike  but uses Unit as the  error type."validaLike  but uses Unit as the  error type.#validaLike  but uses Unit as the  error type.$validaLike  but uses Unit as the  error type.%validaLike  but uses Unit as the  error type.&validaLike  but uses Unit as the  error type.'validaLike  but uses Unit as the  error type.(validaLike  but uses Unit as the  error type.)validaLike  but uses Unit as the  error type.*validaLike  but uses Unit as the  error type.+valida>Build a rule that succeeds if given rule fails and vice versa.Examples?let rule = negateRule "NonPositive" (failureIf (>0) "Positive")runValidator (validate rule) 5 Success 5runValidator (validate rule) 0Failure "NonPositive"!runValidator (validate rule) (-1)Failure "NonPositive",validaLike + but uses Unit as the  error type.-validaA synonym for .:. Satisfies associativity law and hence forms a semigroup..validaBuild a rule that succeeds if either of the given rules succeed. If both fail, the errors are combined. rule1 `orElse` (rule2 `orElse` rule3) = (rule1 `orElse` rule2) `orElse` rule3 / e `orElse` rule = rule rule `orElse` / e = ruleExampleslet rule = failureIf (>0) "Positive" `orElse` failureIf even "Even"runValidator (validate rule) 5 Success 5runValidator (validate rule) 4 Failure ("Positive" :| ["Even"])runValidator (validate rule) 0 Success 0!runValidator (validate rule) (-1) Success (-1)/validaA  that always fails with supplied error. This is the identity of . (i.e -).  falseRule `. ` rule = rule rule `.` falseRule = ruleExamples$runValidator (validate falseRule) 42 Failure ()0validaBuild a rule that  only succeeds if both? of the given rules succeed. The very first failure is yielded.1This is the same as the semigroup operation (i.e b) on . rule1 `andAlso` (rule2 `andAlso` rule3) = (rule1 `andAlso` rule2) `andAlso` rule3 Y `andAlso` rule = rule rule `andAlso` Y = ruleExampleslet rule = failureIf (>0) "Positive" `andAlso` failureIf even "Even"runValidator (validate rule) 5Failure ("Positive" :| [])!runValidator (validate rule) (-2)Failure ("Even" :| [])!runValidator (validate rule) (-1) Success (-1)1validaBuild a rule that succeeds if any of the given rules succeed. If all fail, the errors are combined.  satisfyAny = j .  satisfyAny = k .  satisfyAny = l . /  satisfyAny = m . /2validaBuild a rule that  only succeeds if all? of the given rules succeed. The very first failure is yielded.  satisfyAll = n  satisfyAll = j 0  satisfyAll = k 0  satisfyAll = l 0 Y  satisfyAll = m 0 Y3valida3Build a rule that runs given rule only if input is o.Yields  when input is p.ExamplesrunValidator (validate (optionally (failureIf even "Even"))) (Just 5)Success (Just 5)runValidator (validate (optionally (failureIf even "Even"))) (Just 6)Failure ("Even" :| [])runValidator (validate (optionally (failureIf even "Even"))) NothingSuccess Nothing-  !"#$%&'()*+,-./0123- +,0/.21-   ) "$#*!(%&'3-5Safe8 4valida Convert a  to an P.Given, Validation a b- Failure a is converted to Left a. Success b is converted to Right b.Examples0toEither (Success 'c' :: Validation String Char) Right 'c',toEither (Failure 42 :: Validation Int Char)Left 425valida Convert a P to an .Given,  Either e a-Left e is converted to  Failure e.Right a is converted to  Success a.Examples,fromEither (Right 'c' :: Either String Char) Success 'c''fromEither (Left 42 :: Either Int Char) Failure 426valida$Return True if the given value is a -value, False otherwise.7valida$Return True if the given value is a -value, False otherwise.8validaReturn the contents of a $-value or a default value otherwise.Examples0fromFailure 0 (Success 48 :: Validation Int Int)00fromFailure 0 (Failure 27 :: Validation Int Int)279validaReturn the contents of a $-value or a default value otherwise.Examples0fromSuccess 0 (Success 48 :: Validation Int Int)480fromSuccess 0 (Failure 27 :: Validation Int Int)0:validaExtracts from a list of  all the  values, in order.Examplesfailures [Success 48, Failure "err1", Failure "err2", Success 2, Failure "err3"]["err1","err2","err3"]failures ([Success 1, Success 2, Success 3] :: [Validation String Int])[];validaExtracts from a list of $ all the Success elements, in order.Examplessuccesses [Success 1, Failure "err1", Failure "err2", Success 2, Failure "err3"][1,2]successes ([Failure "err1", Failure "err2", Failure "err3"] :: [Validation String Int])[]<valida+Partitions a list of Either into two lists.All the Left elements are extracted, in order, to the first component of the output. Similarly the Right elements are extracted to the second component of the output. partitionValidations xs = (: xs, ; xs)ExamplespartitionValidations [Success 1, Failure "err1", Failure "err2", Success 2, Failure "err3"](["err1","err2","err3"],[1,2]) 456789:;<Safe8?4=validaAn applicative validator. Validates a predicate on an input when run and returns the  result.?valida=Convenience alias for functions that "select" a record field.qvalida (<>)b? applies input over both validator functions, and combines the  results using b.ExamplesThis essentially reuses the b impl of . i.e Returns the first . But also accumulates s.+let v1 = validate (failureIf (==2) "IsTwo")+let v2 = validate (failureIf even "IsEven")runValidator (v1 <> v2) 5 Success 5runValidator (v1 <> v2) 4 Success 4runValidator (v1 <> v2) 2Failure ("IsTwo" :| ["IsEven"])rvalida pureV creates a =+ that always yields given value wrapped in , ignoring its input.(<*>)\# runs 2 validators to obtain the 2  results and combines them with \. This can be understood as- (Validator ff) <*> (Validator v) = Validator (\inp -> ff inp <*> v inp) i.e Run ff and v on the input, and compose the  results with \.ExamplesrunValidator (pure 5) 42 Success 5+let v1 = validate (failureIf (==2) "IsTwo")+let v2 = validate (failureIf even "IsEven")$runValidator (const <$> v1 <*> v2) 5 Success 5$runValidator (const <$> v1 <*> v2) 4Failure ("IsEven" :| [])$runValidator (const <$> v1 <*> v2) 2Failure ("IsTwo" :| ["IsEven"])svalida fmap^ maps given function over the  result by re-using ^ on it.Examples?runValidator (fmap (+1) (validate $ failureIf (==2) "IsTwo")) 3 Success 4?runValidator (fmap (+1) (validate $ failureIf (==2) "IsTwo")) 2Failure ("IsTwo" :| [])=t>?Simple applicative validation for product types, batteries included!(c) TotallyNotChase, 2021MITtotallynotchase42@gmail.comStablePortableSafeH@validaBuild a validator from a  and a ?.The = first runs given selector on its input to obtain the validation target. Then, it runs the  on the target.If validation is successful, the validation target is put into the  result.ExamplesThis is the primary function for building validators for your record types. To validate a pair, the most basic record type, such that the first element is a non empty string, and the second element is a number greater than 9, you can use:let pairValidator = (,) <$> verify (notEmpty "EmptyString") fst <*> verify (failureIf (<10) "LessThan10") snd4You can then run the validator on your input, using >: >>> runValidator pairValidator ("foo", 12) Success ("foo",12) >>> runValidator pairValidator ("", 12) Failure ( EmptyString; :| []) >>> runValidator pairValidator ("foo", 9) Failure ( LessThan108 :| []) >>> runValidator pairValidator ("", 9) Failure ( EmptyString :| [ LessThan10])AvalidaA synonym for @ with its arguments flipped.Bvalida Relabel a  with a different error.Many combinators, like   and  -, simply return the given error value within NonEmpty upon failure. You can use B to override this return value.Examples0let rule = label "NotEven" (failureUnless' even)runValidator (validate rule) 1Failure "NotEven"let rule = label "DefinitelyNotEven" (failureUnless even "NotEven")runValidator (validate rule) 1Failure "DefinitelyNotEven"CvalidaA synonym for B with its arguments flipped.Dvalida Relabel a = with a different error.Exampleslet validator = labelV "NotEven" (validate (failureUnless' even))runValidator validator 1Failure "NotEven"let validator = labelV "DefinitelyNotEven" (validate (failureUnless even "NotEven"))runValidator validator 1Failure "DefinitelyNotEven"EvalidaA synonym for D with its arguments flipped.FvalidaBuild a basic validator from a .The = runs the rule on its input. If validation is successful, the input is put into the  result. validate rule = @ rule u  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEF?=>F@ABDCE549876;:<A5C6E6      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[Y\]Y^_`aYbcY^deYfgY^hijY^klY^mnoY^pqrsYftYfuYvwYfxYfyYfzYf{Yf|Yf}Yf~YfYYFY^#valida-0.1.0-8eS53wFpB99BMSpdECDPPxValidaValida.Combinators Paths_valida Valida.UtilsValida.ValidationValida.ValidationRuleValida.ValidationUtilsValida.Validator ValidationFailureSuccess validationvalidationConstValidationRulevrule failureIf failureUnless failureIf'failureUnless'mustBeofLength minLengthOf maxLengthOf lengthAbove lengthBelownotEmpty lengthWithin minValueOf maxValueOf valueAbove valueBelow valueWithin onlyContainsatleastContains mustContainmustBe' ofLength' minLengthOf' maxLengthOf' lengthAbove' lengthBelow' notEmpty' lengthWithin' minValueOf' maxValueOf' valueAbove' valueBelow' valueWithin' onlyContains'atleastContains' mustContain' negateRule negateRule'orElse falseRuleandAlso satisfyAny satisfyAll optionallytoEither fromEither isFailure isSuccess fromFailure fromSuccessfailures successespartitionValidations Validator runValidatorSelectorverify-?>labellabelVvalidateversion getBinDir getLibDir getDynLibDir getDataDir getLibexecDir getSysconfDirgetDataFileName neSingletonbase Data.EitherEitherData.Bifoldable bifoldMapGHC.Baseconst$fBifoldableValidation$fTraversableValidationData.Traversabletraversepure$fFoldableValidation Data.FoldablefoldMapmempty$fSemigroupValidation$fApplicativeValidation<*>$fFunctorValidationfmap$fMonoidValidationRule$fSemigroupValidationRule<>ghc-prim GHC.ClassesnotlengthnullGHC.IxinRangeallanyelemfoldl1foldr1foldlfoldrfold GHC.MaybeJustNothing$fSemigroupValidator$fApplicativeValidator$fFunctorValidatorid