fromStringOrNull

Creates an instance of EmailAddress from the string representation of the specified text, or returns null if the string representation of text doesn't match the default pattern.


Calling from Kotlin

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

val text: Any = "[email protected]"
val actual: EmailAddress? = EmailAddress.fromStringOrNull(text)
assertNotNull(actual)

This function is not available from Java code due to its non-explicit support for nullable types.

See the fromString function for throwing an exception instead of returning null in case of invalid text.


fun fromStringOrNull(text: Any, pattern: Any): EmailAddress?

Creates an instance of EmailAddress from the string representation of the specified text. Returns null if the string representation of text doesn't match the string representation of the specified pattern, or if the string representation of pattern doesn't match the default pattern.


Calling from Kotlin

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

val text: Any = "[email protected]"
val pattern: Any = "^[a-z]+@[a-z]+\\.[a-z]+\$"
val actual: EmailAddress? = EmailAddress.fromStringOrNull(text, pattern)
assertNotNull(actual)

This function is not available from Java code due to its non-explicit support for nullable types.

See the fromString function for throwing an exception instead of returning null in case of invalid text or pattern.