of

@ExperimentalSince(version = KotoolsTypesVersion.V5_1_0)
infix fun of(text: String): EmailAddress?

Returns an email address with the specified text, or returns null if the text doesn't match EmailAddressRegex.Companion.default.


Calling from Kotlin

Here's an example of calling this function from Kotlin code:

assertNotNull(EmailAddress of "[email protected]")

Calling from Java

Here's an example of calling this function from Java code:

final EmailAddress result = EmailAddress.of("[email protected]");
Assertions.assertNotNull(result);

@ExperimentalSince(version = KotoolsTypesVersion.V5_1_0)
fun of(text: String, regex: EmailAddressRegex): EmailAddress?

Returns an email address with the specified text, or returns null if the text doesn't match the specified regex.


Calling from Kotlin

Here's an example of calling this function from Kotlin code:

val text = "[email protected]"
val regex: EmailAddressRegex = EmailAddressRegex.alphabetic()
val result: EmailAddress? = EmailAddress.of(text, regex)
assertNotNull(result)

Calling from Java

Here's an example of calling this function from Java code:

final String text = "[email protected]";
final EmailAddressRegex regex = EmailAddressRegex.alphabetic();
final EmailAddress result = EmailAddress.of(text, regex);
Assertions.assertNotNull(result);