Packages

object Validator

Simpler validator abstraction using Cats Validated https://typelevel.org/cats/datatypes/validated.html.

Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Validator
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Type Members

  1. final case class And extends Error with Product with Serializable

    Sequence of errors resulting from the logical conjunction of constraints.

  2. implicit final class BigDecimalMatchers extends AnyVal
  3. implicit final class BooleanOps extends AnyVal
  4. sealed trait Error extends AnyRef
  5. implicit final class IntMatchers extends AnyVal
  6. implicit final class OptionalBigDecimalMatchers extends AnyVal
  7. implicit final class OptionalIntMatchers extends AnyVal
  8. implicit final class OptionalStringMatchers extends AnyVal
  9. final case class Or extends Error with Product with Serializable

    Sequence of errors resulting from the logical disjunction of constraints.

  10. type Result = Either[Error, Unit]

    Validation result type.

  11. final case class Single extends Error with Product with Serializable

    Single error representation.

  12. implicit final class StringMatchers extends AnyVal
  13. type Validate[-T] = (T) => Result

    The validator function type.

  14. implicit final class ValidateOps[T] extends AnyRef
  15. implicit final class ValidationResultOps extends AnyRef

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##: Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. val Valid: Right[Nothing, Unit]

    Successsful validation result alias.

  5. def all[T](constraints: Validate[T]*): Validate[T]

    Conjuction.

    Conjuction. Succeeds only if all constraints are valid.

  6. def allWithComputedPrefix[T](errorPrefix: (T) => String, constraints: Validate[T]*): Validate[T]

    Conjuction.

    Conjuction. Succeeds only if all constraints are valid, otherwise prepend calculated errorPrefix.

  7. def allWithPrefix[T](errorPrefix: String, constraints: Validate[T]*): Validate[T]

    Conjuction.

    Conjuction. Succeeds only if all constraints are valid, otherwise prepend errorPrefix.

  8. def allWithShortCircuit[T](constraints: Validate[T]*): Validate[T]

    Conjuction.

    Conjuction. Succeeds only if all constraints are valid. Breaks the circuit after first invalid result.

  9. def always[T]: Validate[T]

    Validator that always succeeds.

  10. def any[T](constraints: Validate[T]*): Validate[T]

    Disjunction.

    Disjunction. Succeeds if any of the constraints is valid.

  11. def anyWithComputedPrefix[T](errorPrefix: (T) => String, constraints: Validate[T]*): Validate[T]

    Disjunction.

    Disjunction. Succeeds if any of the constraints is valid, otherwise prepend errorPrefix.

  12. def anyWithPrefix[T](errorPrefix: String, constraints: Validate[T]*): Validate[T]

    Disjunction.

    Disjunction. Succeeds if any of the constraints is valid, otherwise prepend errorPrefix.

  13. def apply[T](constraints: Validate[T]*): Validate[T]

    Runs all provided checks.

  14. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  15. def checkEach[T, E](elements: (T) => Seq[E], constraint: Validate[E]): Validate[T]

    Apply constraint to each element of the extracted sequence.

  16. def checkEachIfNonEmpty[T, E](elements: (T) => Seq[E], constraint: Validate[E]): Validate[T]

    Apply constraint to each element of the extracted sequence if non empty.

  17. def checkEachIfNonEmptyWithErrorPrefix[T, E](elements: (T) => Seq[E], constraint: Validate[E], errorPrefix: (Int) => String): Validate[T]

    Apply constraint to each element of the extracted sequence if non empty.

    Apply constraint to each element of the extracted sequence if non empty. If invalid then compute and add prefix to the errors.

  18. def checkEachIfSome[T, E](extract: (T) => Option[Seq[E]], constraint: Validate[E], isValidIfNone: Boolean = true): Validate[T]

    Apply constraint to each element of the extracted sequence if defined.

  19. def checkEachIfSomeWithErrorPrefix[T, E](extract: (T) => Option[Seq[E]], constraint: Validate[E], errorPrefix: (Int) => String, isValidIfNone: Boolean): Validate[T]

    Apply constraint to each element of the extracted sequence if non empty.

    Apply constraint to each element of the extracted sequence if non empty. If invalid then compute and add prefix to the errors.

  20. def checkEachWithErrorPrefix[T, E](elements: (T) => Seq[E], constraint: Validate[E], errorPrefix: (Int) => String): Validate[T]

    Apply constraint to each element of the extracted sequence.

    Apply constraint to each element of the extracted sequence. If invalid then compute and add prefix to the errors.

  21. def checkEither[T, L, R](element: (T) => Either[L, R], constraintLeft: Validate[L], constraintRight: Validate[R]): Validate[T]

    Apply constraint to the extracted property of type Either[L,R].

  22. def checkEquals[T, A](value1: (T) => A, value2: (T) => A, error: String): Validate[T]

    Validate if two properties return the same value.

  23. def checkFromEither[T](test: (T) => Either[String, Any]): Validate[T]

    Validate if the test returns Right, otherwise fail with Left error.

  24. def checkIfAllDefined[T](extractors: Seq[(T) => Option[Any]], expectations: String): Validate[T]

    Check if all extracted optional properties are defined.

  25. def checkIfAllEmpty[T](extractors: Seq[(T) => Option[Any]], expectations: String): Validate[T]

    Check if all extracted optional properties are empty.

  26. def checkIfAllFalse[T](tests: Seq[(T) => Boolean], expectations: String): Validate[T]

    Check if all tests fails

  27. def checkIfAllOrNoneDefined[T](extractors: Seq[(T) => Option[Any]], expectations: String): Validate[T]

    Check if the extracted optional properties are either all defined or all empty.

  28. def checkIfAllTrue[T](tests: Seq[(T) => Boolean], expectations: String): Validate[T]

    Check if all tests passes

  29. def checkIfAtLeastOneIsDefined[T](extractors: Seq[(T) => Option[Any]], expectations: String): Validate[T]

    Check if at least one extracted property is defined.

  30. def checkIfAtLeastOneIsTrue[T](tests: Seq[(T) => Boolean], expectations: String): Validate[T]

    Check if at least one test passes.

  31. def checkIfAtMostOneIsDefined[T](extractors: Seq[(T) => Option[Any]], expectations: String): Validate[T]

    Check if at most one extracted property is defined.

  32. def checkIfAtMostOneIsTrue[T](tests: Seq[(T) => Boolean], expectations: String): Validate[T]

    Check if at most one test passes.

  33. def checkIfOnlyOneIsDefined[T](extractors: Seq[(T) => Option[Any]], expectations: String): Validate[T]

    Check if one and only one extracted property is defined.

  34. def checkIfOnlyOneIsTrue[T](tests: Seq[(T) => Boolean], expectations: String): Validate[T]

    Check if one and only one test passes.

  35. def checkIfOnlyOneSetIsDefined[T](extractors: Seq[Set[(T) => Option[Any]]], expectations: String): Validate[T]

    Check if one and only one set of properties is fully defined.

  36. def checkIfOnlyOneSetIsTrue[T](tests: Seq[Set[(T) => Boolean]], expectations: String): Validate[T]

    Check if one and only one set of tests passes.

  37. def checkIfSome[T, E](element: (T) => Option[E], constraint: Validate[E], isValidIfNone: Boolean = true): Validate[T]

    Apply constraint to the extracted property if defined, otherwise follow isValidIfNone flag.

  38. def checkIsDefined[T](test: (T) => Option[Any], error: String): Validate[T]

    Validate if the test returns Some, otherwise fail with error.

  39. def checkIsEmpty[T](test: (T) => Option[Any], error: String): Validate[T]

    Validate if the test returns None, otherwise fail with error.

  40. def checkIsFalse[T](test: (T) => Boolean, error: String): Validate[T]

    Validate if the test fails, otherwise fail with error.

  41. def checkIsTrue[T](test: (T) => Boolean, error: String): Validate[T]

    Validate if the test passes, otherwise fail with error.

  42. def checkNotEquals[T, A](value1: (T) => A, value2: (T) => A, error: String): Validate[T]

    Validate if two properties return different value.

  43. def checkProp[T, E](element: (T) => E, constraint: Validate[E]): Validate[T]

    Validate with the provided constraint applied to the extracted property.

  44. def checkWith[T, E](element: (T) => E, constraint: Validate[E]): Validate[T]

    Validate with the provided constraint applied to the extracted property.

  45. def checkWithImplicitly[T, E](element: (T) => E)(implicit constraint: Validate[E]): Validate[T]

    Validate using the provided implicit constraint applied to the extracted property.

  46. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native()
  47. def conditionally[T](test: (T) => Boolean, constraintWhenTrue: Validate[T], constraintWhenFalse: Validate[T]): Validate[T]

    Depending on the test result follow continue with either first or second constraint.

  48. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  49. def equals(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  50. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable])
  51. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  52. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  53. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  54. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  55. def never[T]: Validate[T]

    Validator that always fails.

  56. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  57. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  58. def product[A, B, C, D](constraintA: Validate[A], constraintB: Validate[B], constraintC: Validate[C], constraintD: Validate[D]): Validate[(A, B, C, D)]

    Combine four constraints to make a constraint on a tuple.

  59. def product[A, B, C](constraintA: Validate[A], constraintB: Validate[B], constraintC: Validate[C]): Validate[(A, B, C)]

    Combine three constraints to make a constraint on a triplet.

  60. def product[A, B](constraintA: Validate[A], constraintB: Validate[B]): Validate[(A, B)]

    Combine two constraints to make a constraint on a pair.

  61. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  62. def toString(): String
    Definition Classes
    AnyRef → Any
  63. def validate[T](constraints: Validate[T]*): Validate[T]

    Runs all provided checks.

    Runs all provided checks. Provided as a named alias to the apply method.

  64. def validateCollectionNonEmpty(errorMessage: String): (Iterable[_]) => Result
  65. def validateStringNonEmpty(errorMessage: String): Validate[String]
  66. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  67. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  68. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()
  69. def when[T](guardConstraint: Validate[T], constraintWhenValid: Validate[T], constraintWhenInvalid: Validate[T]): Validate[T]

    Depending on the guard constraint result continue with either first or second constraint.

  70. def whenFalse[T](test: (T) => Boolean, constraintWhenFalse: Validate[T]): Validate[T]

    If the test is false then try the next constraint, otherwise valid.

  71. def whenInvalid[T](guardConstraint: Validate[T], constraintWhenInvalid: Validate[T]): Validate[T]

    If the guard constraint is invalid then try next constraint.

  72. def whenTrue[T](test: (T) => Boolean, constraintWhenTrue: Validate[T]): Validate[T]

    If the test is true then check the next constraint, otherwise valid.

  73. def whenValid[T](guardConstraint: Validate[T], constraintWhenValid: Validate[T]): Validate[T]

    If the guard constraint is valid then check next constraint.

  74. object Error
  75. object Invalid

    Invalid result helpers.

Inherited from AnyRef

Inherited from Any

Ungrouped