NonEmptyString

neotype.common.package$package.NonEmptyString
object NonEmptyString extends Subtype[String]

Attributes

Graph
Supertypes
class Subtype[String]
class TypeWrapper[String]
class Object
trait Matchable
class Any
Self type

Members list

Type members

Inherited and Abstract types

opaque type Type

Attributes

Inherited from:
Subtype

Value members

Concrete methods

inline override def validate(input: String): Boolean | String

Validates the input and returns a boolean or an error message.

Validates the input and returns a boolean or an error message.

Attributes

Definition Classes

Inherited methods

inline def apply(inline input: String): Type

Creates a new instance of the newtype.

Creates a new instance of the newtype.

If the validate method is not defined for this, it will simply wrap the input in the neotype.

If validate is defined, it will be called at compile-time to check if the input is valid. If it fails, it will raise a compile-time error. input should be a literal or a constant expression, a compile-time known value—otherwise, you should use the make method instead.

Attributes

Inherited from:
TypeWrapper
inline def applyAll(inline values: String*): List[Type]

Creates a list of newtype instances.

Creates a list of newtype instances.

This will essentially call apply for each value in the list, performing the same compile-time validation for each element.

If any of the elements fail validation, it will raise a compile-time error. Otherwise, it will return a list of newtype instances.

Attributes

Inherited from:
TypeWrapper
final def make(input: String): Either[String, Type]

Attempts to create a new instance of the Subtype for the given input by calling the validate method.

Attempts to create a new instance of the Subtype for the given input by calling the validate method.

If the validation fails, it will return a Left with an error message. If the validation succeeds, it will return a Right with the new instance.

Attributes

Inherited from:
Subtype
inline def unsafeMake(inline input: String): Type

WARNING! Creates a new instance of the newtype without performing any validation. ONLY USE THIS IF YOU KNOW WHAT YOU'RE DOING.

WARNING! Creates a new instance of the newtype without performing any validation. ONLY USE THIS IF YOU KNOW WHAT YOU'RE DOING.

This method should be used with caution, as it bypasses any validation defined in the validate method. It is recommended to use the apply method instead, which performs compile-time validation of the input.

Attributes

Inherited from:
Subtype
inline def unsafeMakeF[F[_]](inline input: F[String]): F[Type]

WARNING! This casts an F[A] to an F[Type] without performing any validation. ONLY USE THIS IF YOU KNOW WHAT YOU'RE DOING.

WARNING! This casts an F[A] to an F[Type] without performing any validation. ONLY USE THIS IF YOU KNOW WHAT YOU'RE DOING.

If, for instance, you have a List[A] and you want to convert it to a List[Type], you can use this method to do so.

Attributes

Inherited from:
Subtype

Givens

Inherited givens

transparent inline given given_WithType_A_Type: WithType[String, Type]

Attributes

Inherited from:
Subtype