final case class PValidator[F[_], E, A, B](validate: (A) ⇒ F[E], f: (A) ⇒ B)(implicit FF: Traverse[F], M: MonoidK[F]) extends Product with Serializable
PValidator
wraps up a validation function validate: A => F[E]
which validates the input A
and returns a structure
of error messages F[E]
.
The P
in PValidator
denotes the fact that this validation is polymorphic, in the sense that its input does not have to be of the same type as its output.
This may be useful when a successful validation provides some knowledge about the value that is being validated that can be used to refine its type.
For example, a required
validator makes use of the fact that it has ensured that an Option[A]
is not empty to safely unwrap the option's inner value.
- Alphabetic
- By Inheritance
- PValidator
- Serializable
- Serializable
- Product
- Equals
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Instance Constructors
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
all[C, X, Y](t: PTraversal[B, C, X, Y])(that: PValidator[F, E, X, Y]): PValidator[F, E, A, C]
Combine this validator with a validator
that
which validates elements of a traversable structure extracted using the traversalt
. -
def
all[M[_], C](f: (A) ⇒ M[C])(that: PValidator[F, E, C, _])(implicit arg0: Traverse[M]): PValidator[F, E, A, B]
Combine this validator with a validator
that
which validates elements of a traversable structure extracted using the functionf
. -
def
all2[C, D](l: Lens[B, C], t: Traversal[B, D])(that: PValidator[F, E, (C, D), _]): PValidator[F, E, A, B]
Combine this validator with a validator
that
which validates tuples of an inner value extracted using the lensl
and elements of a traversable structure extracted using the traversalt
. -
def
all2[M[_], C, D](f: (A) ⇒ C, g: (A) ⇒ M[D])(that: PValidator[F, E, (C, D), _])(implicit TM: Traverse[M]): PValidator[F, E, A, B]
Combine this validator with a validator
that
which validates tuples of a single inner value extracted using the functionf
and elements of a traversable structure extracted using the functiong
. -
def
allIndexed[C, X, Y](t: PTraversal[B, C, (X, Int), Y])(that: PValidator[F, E, (X, Int), Y]): PValidator[F, E, A, C]
Combine this validator with a validator
that
which validates tuples of elements and their indices in a traversable structure extracted using the traversalt
. -
def
allIndexed[M[_], C](g: (A) ⇒ M[C])(that: PValidator[F, E, (C, Int), _])(implicit TM: Traverse[M]): PValidator[F, E, A, B]
Combine this validator with a validator
that
which validates tuples of elements and their indices in a traversable structure extracted using the functionf
. -
def
and(that: PValidator[F, E, A, _]): PValidator[F, E, A, B]
Combine this validator with
that
to produce a validator which runs both validations.Combine this validator with
that
to produce a validator which runs both validations.This function ignores the post-processing step of the second validator
that
. -
def
andThen[C](that: PValidator[F, E, B, C]): PValidator[F, E, A, C]
Run
this
validation and thenthat
validation on the input and if both pass, perform the post-processing of each validator in turn. -
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
at[M[_], C](f: (A) ⇒ M[C], i: Long)(that: PValidator[F, E, Option[C], _])(implicit TM: Traverse[M]): PValidator[F, E, A, B]
Combine this validator with a validator
that
which validates an optional value at indexi
of a traversable structure extracted using the functionf
. -
def
clone(): AnyRef
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @native() @throws( ... )
-
def
contramap[Z](g: (Z) ⇒ A): PValidator[F, E, Z, B]
Adapt this validator to an input of type
Z
using the functiong
. -
def
dimap[Z, C](g: (Z) ⇒ A)(h: (B) ⇒ C): PValidator[F, E, Z, C]
Adapt this validator to an input of type
Z
using the functiong
and maps its output usingh
. -
def
element[C, X](t: POptional[B, C, X, X])(that: PValidator[F, E, Option[X], _]): PValidator[F, E, A, C]
Combine this validator with a validator
that
which validates an specific element of a traversable structure extracted using the traversalt
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- val f: (A) ⇒ B
-
def
finalize(): Unit
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
def
first[M[_], C](f: (A) ⇒ M[C])(that: PValidator[F, E, Option[C], _])(implicit FM: Foldable[M]): PValidator[F, E, A, B]
Combine this validator with a validator
that
which validates an optional value at the first index of a traversable structure extracted using the functionf
. -
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
has[C, X, Y](l: PLens[B, C, X, Y])(that: PValidator[F, E, X, Y]): PValidator[F, E, A, C]
Combine this validator with a validator
that
which validates an inner value extracted using the lensl
. -
def
has[C](f: (A) ⇒ C)(that: PValidator[F, E, C, _]): PValidator[F, E, A, B]
Combine this validator with a validator
that
which validates an inner value extracted using the functionf
. -
def
has2[X, Y](l: Lens[B, X], r: Lens[B, Y])(that: PValidator[F, E, (X, Y), _]): PValidator[F, E, A, B]
Combine this validator with a validator
that
which validates a tuple of inner values extracted using the lensesl
andr
. -
def
has2[C, D](f: (A) ⇒ C, g: (A) ⇒ D)(that: PValidator[F, E, (C, D), _]): PValidator[F, E, A, B]
Combine this validator with a validator
that
which validates a tuple of inner values extracted using the functionsf
andg
. -
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
def
leftMap[EE](g: (E) ⇒ EE): PValidator[F, EE, A, B]
Transform any errors produced by this validator using the function
g
. -
def
map[C](g: (B) ⇒ C): PValidator[F, E, A, C]
Add an additional post-processing step
g
to the output value of this validator which is applied on success. -
def
map2[C, D](that: PValidator[F, E, A, C])(g: (B, C) ⇒ D): PValidator[F, E, A, D]
Combine this validator with
that
to produce a validator which runs both validations.Combine this validator with
that
to produce a validator which runs both validations. Use the functiong
to combine the post-processed values of both validators into a single value. -
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
def
optional: PValidator[F, E, Option[A], Option[B]]
Apply this validator to the inner value of an
Option[A]
, passing when the Option is empty. -
def
or[C](that: PValidator[F, E, C, B]): PValidator[F, E, Either[A, C], B]
Combine this validator with
that
, a validator for a different type, to produce a validator forEither
of this andthat
's validation. -
def
over[M[_]](implicit TM: Traverse[M]): PValidator[F, E, M[A], M[B]]
Extend this validator over an
M[A]
that is traversable so that every element is validated. -
def
product[C](that: PValidator[F, E, A, C]): PValidator[F, E, A, (B, C)]
Combine this validator with
that
to produce a validator which runs both validations.Combine this validator with
that
to produce a validator which runs both validations.This function runs the post-processing steps of both validators on the input and returns each of the results as a tuple.
-
def
required(e: F[E]): PValidator[F, E, Option[A], B]
Apply this validator to the inner element of an
Option[A]
, failing with error messagese
when the Option is empty. -
def
run[G[_]](a: A)(implicit A: ApplicativeError[G, F[E]]): G[B]
A specialization of
runWith
which runs the validation ona
and returns errors in the default error message structureF[E]
. -
def
runK[G[_], H[_]](a: A)(g: ~>[F, H])(implicit A: ApplicativeError[G, H[E]]): G[B]
A specialization of
runWith
which runs the validation ona
and uses the natural transformationg
to translate the error message structureF[E]
intoH[E]
. -
def
runNel[G[_, _]](a: A)(implicit A: ApplicativeError[[β$0$]G[NonEmptyList[E], β$0$], NonEmptyList[E]]): G[NonEmptyList[E], B]
A specialization of
runWith
which is designed for use with binary type constructors (e.g.A specialization of
runWith
which is designed for use with binary type constructors (e.g.Either
,Validated
). The error message type isNonEmptyList[E]
. -
def
runWith[G[_], EE](a: A)(g: (F[E]) ⇒ EE)(implicit A: ApplicativeError[G, EE]): G[B]
Runs the validation function.
Runs the validation function. If the validation succeeds, the post-processing function of this validator
f: A => B
is used to transform the result value.Otherwise, the function
g
is used to convert the error message structure produced by the validation into the desired resultEE
.The function provided here is used to select the
ApplicativeError
instance that is used to lift pure values intoG[_]
and to raise errorsEE
. -
def
run_[G[_]](a: A)(implicit A: ApplicativeError[G, Unit]): G[B]
A specialization of
runWith
which runs the validation ona
and uses aG[_]
which returns no errors on failure, such asOption
. -
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
- val validate: (A) ⇒ F[E]
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @throws( ... )