Opaque

trait Opaque[OpaqueType, Unwrapped](using ev: OpaqueType =:= Unwrapped)
class Object
trait Matchable
class Any

Value members

Concrete methods

def apply(unwrapped: Unwrapped): OpaqueType

Creates an instance of OpaqueType from unwrapped value.

Creates an instance of OpaqueType from unwrapped value.

Value Params
unwrapped

value to be validated, transformed and wrapped in OpaqueType

Returns

OpaqueType wrapping validated & transformed unwrapped value

Throws
IllegalArgumentException

with reason, if validation fails

def from(unwrapped: Unwrapped): Either[String, OpaqueType]

Validates and transforms (ex. sanitizes) unwrapped value. By default, there is no validation or transformation.

Validates and transforms (ex. sanitizes) unwrapped value. By default, there is no validation or transformation.

Value Params
unwrapped

value to be validated and transformed

Returns

Left(reason) if validation fails; Right(opaqueType) if validation succeeds

def unsafe(unwrapped: Unwrapped): OpaqueType

Creates an instance of OpaqueType from unwrapped value in an unsafe manner - without validation or transformation.

Creates an instance of OpaqueType from unwrapped value in an unsafe manner - without validation or transformation.

Value Params
unwrapped

value to be wrapped in OpaqueType

Returns

OpaqueType wrapping unwrapped value

protected def validate(unwrapped: Unwrapped): Either[String, OpaqueType]

Validates and transforms (ex. sanitizes) unwrapped value.

Validates and transforms (ex. sanitizes) unwrapped value.

Value Params
unwrapped

value to be validated and transformed

Returns

Left(reason) if validation fails; Right(opaqueType) if validation succeeds

Concrete fields

final lazy val cc1Rep: CaseClass1Rep[OpaqueType, Unwrapped]

Extensions

Extensions

extension (w: OpaqueType)
def unwrap: Unwrapped

Unwraps value wrapped in OpaqueType.

Unwraps value wrapped in OpaqueType.

Returns

unwrapped value