A type class that defines how to validate an instance of A
.
Can be thought of as a A => F[ValidatedNec[E, Unit]]
function.
Attributes
- Companion:
- object
- Graph
- Supertypes
Members list
Value members
Concrete methods
Combines two validators of the same type into one. If first validator fails, second one is not invoked. Example:
Combines two validators of the same type into one. If first validator fails, second one is not invoked. Example:
scala> val value = "value"
scala> val v1 = dupin.basic.BasicValidator.failure[String](_ => "failure1")
scala> val v2 = dupin.basic.BasicValidator.failure[String](_ => "failure2")
scala> val v3 = dupin.basic.BasicValidator.success[String]
scala> (v1 andThen v2).validate(value)
res0: cats.Id[cats.data.ValidatedNec[String,User]] = Invalid(Chain(failure1))
scala> (v3 andThen v2).validate(value)
res1: cats.Id[cats.data.ValidatedNec[String,User]] = Invalid(Chain(failure2))
Attributes
Contravariant map without path changes. Example:
Contravariant map without path changes. Example:
scala> case class User(age: Int)
scala> val user = User(1)
scala> val validator = dupin.basic.BasicValidator.failure[Int](c => s"${c.path} is wrong")
scala> validator.comap[User](_.age).validate(user)
res0: cats.Id[cats.data.ValidatedNec[String,User]] = Invalid(Chain(. is wrong))
scala> validator.comapP[User](_.age).validate(user)
res1: cats.Id[cats.data.ValidatedNec[String,User]] = Invalid(Chain(.age is wrong))
Attributes
Contravariant map with explicit path prefix.
Contravariant map with explicit path prefix.
Attributes
Combines two validators of the same type into one. If either validator fails, error is returned. If both validators fail, errors from both validators are returned. Example:
Combines two validators of the same type into one. If either validator fails, error is returned. If both validators fail, errors from both validators are returned. Example:
scala> val value = "value"
scala> val v1 = dupin.basic.BasicValidator.failure[String](_ => "failure1")
scala> val v2 = dupin.basic.BasicValidator.failure[String](_ => "failure2")
scala> val v3 = dupin.basic.BasicValidator.success[String]
scala> (v1 combine v2).validate(value)
res0: cats.Id[cats.data.ValidatedNec[String,User]] = Invalid(Chain(failure1, failure2))
scala> (v3 combine v2).validate(value)
res1: cats.Id[cats.data.ValidatedNec[String,User]] = Invalid(Chain(failure2))
Attributes
Combines this
with validator from context.
Combines this
with field validator using explicit path.
Combines this
with root validator passed by separate arguments.
Replaces failure messages with supplied values.
Optimized version of .handleErrorWith(_ => Validator.failure(m1, ms))
Replaces failure messages with supplied values.
Optimized version of .handleErrorWith(_ => Validator.failure(m1, ms))
Attributes
Lifts validator to G[_]
type using Traverse
instance, adds index as path prefix.
Lifts validator to G[_]
type using Traverse
instance, adds index as path prefix.
Attributes
Combines two validators of the same type into one. If either validator fails, success is returned. If both validators fail, errors from right validator are returned. Example:
Combines two validators of the same type into one. If either validator fails, success is returned. If both validators fail, errors from right validator are returned. Example:
scala> val value = "value"
scala> val v1 = dupin.basic.BasicValidator.failure[String](_ => "failure1")
scala> val v2 = dupin.basic.BasicValidator.failure[String](_ => "failure2")
scala> val v3 = dupin.basic.BasicValidator.success[String]
scala> (v1 orElse v2).validate(value)
res0: cats.Id[cats.data.ValidatedNec[String,User]] = Invalid(Chain(failure2))
scala> (v3 orElse v2).validate(value)
res1: cats.Id[cats.data.ValidatedNec[String,User]] = Valid(value)
Attributes
Inherited methods
Contravariant map with macros generated path prefix.
Contravariant map with macros generated path prefix.
Attributes
- See also:
[comap]
- Inherited from:
- ValidatorBinCompat
Combines with field validator using macros generated path.
Combines with field validator using macros generated path.
Attributes
- Inherited from:
- ValidatorBinCompat
Combines with field validator from context using macros generated path.
Combines with field validator from context using macros generated path.
Attributes
- Inherited from:
- ValidatorBinCompat
Combines with implicit field validator using macros generated path
Combines with implicit field validator using macros generated path
Attributes
- Inherited from:
- ValidatorBinCompat
Combines with field validator passed by separate arguments using macros generated path.
Combines with field validator passed by separate arguments using macros generated path.
Attributes
- Inherited from:
- ValidatorBinCompat
Attributes
- Inherited from:
- ValidatorBinCompat