ValidationModule

@implicitNotFound("ValidationModule[${F}, ${VR}, ${E}] not found")
abstract class ValidationModule[F[_], VR[_], E](implicit val F: ValidationEffect[F], val VR: ValidationResult[VR]) extends GenericSyntax[F, VR, E] with FailSyntax[F, VR, E] with BooleanSyntax[F, VR, E] with EffectValidationResultSyntax[F, VR, E] with NumericSyntax[F, VR, E] with OptionSyntax[F, VR, E] with StringSyntax[F, VR, E] with IterableSyntax[F, VR, E] with MapSyntax[F, VR, E] with PolicySyntax[F, VR, E] with FieldSyntax with ValidationResultSyntax

God object that provides all validation syntax for choosen Effect - F[_], ValidationResult - VR[_] and Error - E Requires user to provide implicit instances of ValidationEffect and ValidationResult typeclasses for choosen F[_] and VR[_].

trait PolicySyntax[F, VR, E]
trait MapSyntax[F, VR, E]
trait IterableSyntax[F, VR, E]
trait StringSyntax[F, VR, E]
trait OptionSyntax[F, VR, E]
trait NumericSyntax[F, VR, E]
trait BooleanSyntax[F, VR, E]
trait FailSyntax[F, VR, E]
trait GenericSyntax[F, VR, E]
class Object
trait Matchable
class Any
class AccumulateVM[F, E]
class FailFastVM[F, E]
object DefaultFailFastVM.type

Type members

Classlikes

object Policy

Types

type Policy[P] = ValidationPolicy[P, F, VR, E]

Shortcut for ValidationPolicy

Shortcut for ValidationPolicy

Value members

Concrete methods

def and(a: F[VR[E]], b: F[VR[E]]): F[VR[E]]

Combines a and b using AND. Short-circuits if ValidationResult.strategy is ValidationResult.Strategy.FailFast.

Combines a and b using AND. Short-circuits if ValidationResult.strategy is ValidationResult.Strategy.FailFast.

def and(list: List[F[VR[E]]]): F[VR[E]]

Combines all validations using AND

Combines all validations using AND

@inline
def assert[P](field: Field[P], cond: P => Boolean, error: Field[P] => E): F[VR[E]]

Returns ValidationResult.valid if cond is true else fails with provided error

Returns ValidationResult.valid if cond is true else fails with provided error

@inline
def assertF[P](field: Field[P], cond: P => F[Boolean], error: Field[P] => E): F[VR[E]]

Returns ValidationResult.valid if cond is true else fails with provided error

Returns ValidationResult.valid if cond is true else fails with provided error

@inline
def assertTrue[P](field: Field[P], cond: => Boolean, error: Field[P] => E): F[VR[E]]

Returns ValidationResult.valid if cond is true else fails with provided error

Returns ValidationResult.valid if cond is true else fails with provided error

@inline
def check[P](field: Field[P], f: Field[P] => VR[E]): F[VR[E]]

Applies f validation to Field#value

Applies f validation to Field#value

@inline
def checkF[P](field: Field[P], f: Field[P] => F[VR[E]]): F[VR[E]]

Applies f effectful validation to Field#value

Applies f effectful validation to Field#value

def combineAll(list: List[F[VR[E]]]): F[VR[E]]

Alias for and

Alias for and

@inline
def fold(list: List[F[VR[E]]], combine: (F[VR[E]], F[VR[E]]) => F[VR[E]]): F[VR[E]]

Combines all validations using combine function. This has minor optimistions that checks size to handle simple cases.

Combines all validations using combine function. This has minor optimistions that checks size to handle simple cases.

def or(a: F[VR[E]], b: F[VR[E]]): F[VR[E]]

Combines a and b using OR. Short-circuits if a is valid

Combines a and b using OR. Short-circuits if a is valid

def or(list: List[F[VR[E]]]): F[VR[E]]

Combines all validations using OR

Combines all validations using OR

Concrete fields

val valid: VR[E]

Valid VR[E] instance

Valid VR[E] instance

val validF: F[VR[E]]

Valid F[VR[E]] instance

Valid F[VR[E]] instance

Extensions

Inherited extensions

extension [P](builder: ValidationPolicyBuilder[P, F, VR, E])
inline def subRule[S](inline selector: P => S)(rules: Field[S] => F[VR[E]]*): ValidationPolicyBuilder[P, F, VR, E]

Adds new subrule to builder. Uses selector to create Field, rules are applied to that field

Adds new subrule to builder. Uses selector to create Field, rules are applied to that field

Inherited from:
PolicySyntax
inline def subRule2[S1, S2](inline selector1: P => S1, inline selector2: P => S2)(rules: (Field[S1], Field[S2]) => F[VR[E]]*): ValidationPolicyBuilder[P, F, VR, E]

Adds new subrule to builder. Same as subRule but for 2 subrules

Adds new subrule to builder. Same as subRule but for 2 subrules

Inherited from:
PolicySyntax
extension [P](field: Field[P])
def any(using II: IsIterable[P], M: ValidationModule[F, VR, E])(check: (Field[A], Int) => F[VR[E]]): F[VR[E]]

Applies check to each collection element, any should succeed

Applies check to each collection element, any should succeed

Inherited from:
IterableSyntax
def any(using II: IsIterable[P], M: ValidationModule[F, VR, E])(check: Field[A] => F[VR[E]]): F[VR[E]]

Applies check to each collection element, any should succeed

Applies check to each collection element, any should succeed

Inherited from:
IterableSyntax
def each(using II: IsIterable[P], M: ValidationModule[F, VR, E])(check: (Field[A], Int) => F[VR[E]]): F[VR[E]]

Applies check to each collection element, each should succeed

Applies check to each collection element, each should succeed

Inherited from:
IterableSyntax
def each(using II: IsIterable[P], M: ValidationModule[F, VR, E])(check: Field[A] => F[VR[E]]): F[VR[E]]

Applies check to each collection element, each should succeed

Applies check to each collection element, each should succeed

Inherited from:
IterableSyntax
def maxSize(using II: IsIterable[P], M: ValidationModule[F, VR, E])(max: Int)(using FailWithMaxSize[E]): F[VR[E]]

Checks that collection maximum size is max

Checks that collection maximum size is max

Inherited from:
IterableSyntax
def minSize(using II: IsIterable[P], M: ValidationModule[F, VR, E])(min: Int)(using FailWithMinSize[E]): F[VR[E]]

Checks that collection minimum size is min

Checks that collection minimum size is min

Inherited from:
IterableSyntax
def nonEmpty(using II: IsIterable[P], M: ValidationModule[F, VR, E])(using FailWithEmpty[E]): F[VR[E]]

Checks that collection is not empty

Checks that collection is not empty

Inherited from:
IterableSyntax
extension (field: Field.type)
inline def from[V](inline value: V): Field[V]

Returns Field that has provided value and infers its FieldPath from field selects

Returns Field that has provided value and infers its FieldPath from field selects

Example:

scala> val request = Request(User("ann"))
val request: Request = Request(User(ann))
scala> val field = Field.from(request.user.name)
val field: jap.fields.Field[String] = request.user.name:ann
Inherited from:
FieldSyntax
inline def sub[V](inline value: V): Field[V]

Similar to Field.from but drops first selector path

Similar to Field.from but drops first selector path

Example:

scala> val request = Request(User("ann"))
val request: Request = Request(User(ann))
scala> val field = Field.sub(request.user.name)
val field: jap.fields.Field[String] = user.name:ann
Inherited from:
FieldSyntax
extension [P](field: Field[P])
inline def sub[S](inline selector: P => S): Field[S]

Returns subfield using selector function to extract value and as path

Returns subfield using selector function to extract value and as path

Example

scala> val request = Request(User("ann"))
scala> val field = Field.from(request)
val field: jap.fields.Field[Request] = request:Request(User(ann))
scala> field.sub(_.user.name)
val res1: jap.fields.Field[String] = request.user.name:ann
Inherited from:
FieldSyntax

Implicits

Implicits

implicit val F: ValidationEffect[F]
implicit def Module: ValidationModule[F, VR, E]

Syntax classes requires implicit ValidationModule in scope

Syntax classes requires implicit ValidationModule in scope

implicit val VR: ValidationResult[VR]

Inherited implicits

final implicit def toBooleanFieldOps(field: Field[Boolean]): BooleanFieldOps[F, VR, E]
Inherited from:
BooleanSyntax
final implicit def toEffectValidationResultOps(a: F[VR[E]]): EffectValidationResultOps[F, VR, E]
final implicit def toEffectValidationResultSequenceOps(iterable: Iterable[F[VR[E]]]): EffectValidationResultSequenceOps[F, VR, E]
final implicit def toFailFieldOps[P](field: Field[P]): FailFieldOps[P, F, VR, E]
Inherited from:
FailSyntax
final implicit def toFieldOps[P](field: Field[P]): FieldOps[P, F, VR, E]
Inherited from:
GenericSyntax
final implicit def toMapFieldOps[K, V](field: Field[Map[K, V]]): MapFieldOps[K, V, F, VR, E]
Inherited from:
MapSyntax
final implicit def toNumericFieldOps[P](field: Field[P]): NumericFieldOps[P, F, VR, E]
Inherited from:
NumericSyntax
final implicit def toOptionFieldOps[P](field: Field[Option[P]]): OptionFieldOps[P, F, VR, E]
Inherited from:
OptionSyntax
final implicit def toStringFieldOps(field: Field[String]): StringFieldOps[F, VR, E]
Inherited from:
StringSyntax
final implicit def toValidationResultIdOps[E](error: E): ValidationResultIdOps[E]
Inherited from:
ValidationResultSyntax
final implicit def toValidationResultOps[VR[_] : ValidationResult, E](vr: VR[E]): ValidationResultOps[VR, E]
Inherited from:
ValidationResultSyntax