package validation
A set of cats related data types for validation specific to our needs that included data driven validation while still supporting multple styles such as DSL or non-DSL.
Overview
By using cats you can compose on the Result or the Validator depending on your needs. Some additonal methods for defining a Validator are provided using the Tester classes--smart constructors for Validator.
- Alphabetic
- By Inheritance
- validation
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Type Members
- trait Algebra[F[_]] extends AnyRef
A validation concept involves a function that evaluates a value and the ability to create a success or failure based on an input type wrapped in
F
.A validation concept involves a function that evaluates a value and the ability to create a success or failure based on an input type wrapped in
F
.F
must be able to express the concept of success or failure. Note that at this level,F
could be a product type or sum type (coproduct). Usually they are sum types.Should we consider message gathering to be a "logging" activity and use a writer monad?
- trait ApplicativeAlgebra[F[_], E] extends Algebra[F]
Encode valid/invalid via an
ApplicativeError
and failure via anE
. - trait ConversionOps[F[_], E] extends AnyRef
- case class Error(message: String, path: Path = Path.empty) extends Product with Serializable
Useful instance for the formulation below.
Useful instance for the formulation below. You can define your own.
- type Errors = Type[Error]
Convenience type, as if Validated[Errors, T]
- trait LogicOps[F[_], E] extends AnyRef
- trait NumberOps[F[_], E] extends AnyRef
- trait ObjectOps[F[_], E] extends AnyRef
- trait OptionOps[F[_], E] extends AnyRef
- type Path = Seq[String]
Need to expand to include indexed positions, etc.
- type Result[T] = Validated[NonEmptyChain[Error], T]
Allow multiple errors if invalid, Validated has rich combinators including sequencing.
- trait StrictApplicativeAlgebra[F[_], E] extends ApplicativeAlgebra[F, E]
A boolean test for validity is a strict test
- trait StringOps[F[_], E] extends AnyRef
- trait ValidationAlgebra[F[_], E] extends StringOps[F, E] with ObjectOps[F, E] with LogicOps[F, E] with NumberOps[F, E] with OptionOps[F, E] with ConversionOps[F, E]
- trait ValidationAlgebraInstances extends AnyRef
- type Validator[F[_], A, B] = Kleisli[F, A, B]
Enable cats combinators including sequencing
Value Members
- case object BuildInfo extends Product with Serializable
This object was generated by sbt-buildinfo.
- object Path
- object StrictApplicativeAlgebra
- object ValidationAlgebra extends ValidationAlgebraInstances