package prelude
Ordering
- Alphabetic
Visibility
- Public
- Protected
Type Members
- sealed trait Assertion[-A] extends AnyRef
- sealed trait AssertionError extends AnyRef
- trait Liftables extends AnyRef
- Annotations
- @silent("pattern var .* in method unapply is never used: use a wildcard `_` or suppress this warning with .*")
- trait QuotedAssertion[A] extends AnyRef
- final case class assertionQuote[A](assertion: Assertion[A]) extends Annotation with StaticAnnotation with Product with Serializable
- final case class assertionString(string: String) extends Annotation with StaticAnnotation with Product with Serializable
Value Members
- object Assertion
An
Assertion[A]
is essentially a composable predicate fromA => Boolean
.An
Assertion[A]
is essentially a composable predicate fromA => Boolean
. They can be composed with standard Boolean operators of&&
,||
and!
. This is primarily intended to be used withNewtype
andSubtype
, enhancing them with compile-time time validation.For example, if you'd like to validate that a particular Int is precisely 4 digits long, you can create the following refined Newtype. (Note that the syntax is slightly difference between Scala 2 and Scala 3).
type Pin = Pin.Type object Pin extends Newtype[Int] { // Scala 2 Syntax def assertion = assert(Assertion.between(1000, 9999)) // Scala 3 Syntax override inline def assertion = Assertion.between(1000, 9999) } // PowerOfTwo(1000) compiles // PowerOfTwo(5412) compiles // PowerOfTwo(34567) fails with "34567 did not satisfy between(1000, 9999)" // PowerOfTwo(234) fails with "123 did not satisfy between(1000, 9999)"
- object AssertionError