NewtypeValidated

abstract class NewtypeValidated[Src] extends Newtype[Src] with NewValidated[Src]

A validated Newtype.

This class is for defining newtypes with a builder that validates values.

Example:

 type EmailAddress = EmailAddress.Type

 object EmailAddress extends NewtypeValidated[String] {
   def apply(v: String): Either[BuildFailure[Type], Type] =
     if (v.contains("@"))
       Right(unsafeCoerce(v))
     else
       Left(BuildFailure("missing @"))
 }
trait NewValidated[Src]
class Newtype[Src]
trait NewtypeTrait[Src]
trait NewEncoding[Src]
class Object
trait Matchable
class Any

Type members

Inherited types

override opaque type Type
Inherited from:
NewtypeTrait

Value members

Inherited methods

def apply(value: Src): Either[BuildFailure[Type], Type]
Inherited from:
NewValidated
final inline protected def derive[F[_]](implicit ev: F[Src]): F[Type]
Inherited from:
NewEncoding
final def unapply[A](a: A)(implicit ev: A =:= Type): Some[Src]
Inherited from:
NewValidated
final def unsafe(value: Src): Type
Inherited from:
NewValidated
final inline protected def unsafeCoerce(value: Src): Type
Inherited from:
NewEncoding

Extensions

Inherited extensions

extension (self: Type)
final inline def value: Src
Inherited from:
NewEncoding

Implicits

Inherited implicits

final implicit val builder: Aux[Type, Src]
Inherited from:
NewValidated
implicit val codec: Aux[Type, Src]
Inherited from:
NewEncoding
implicit val typeInfo: TypeInfo[Type]
Inherited from:
NewEncoding