orNull
Creates an instance of EmailAddress from the specified text, or returns null
if the text doesn't match the default pattern.
Calling from Kotlin
Here's an example of calling this method from Kotlin code:
val text = "[email protected]"
val emailAddress: EmailAddress? = EmailAddress.orNull(text)
assertNotNull(emailAddress)
This method is not available from Java code due to its non-explicit support for nullable types.
See the orThrow method for throwing an exception instead of returning null
in case of invalid text.
Creates an instance of EmailAddress from the specified text. Returns null
if the text doesn't match the specified pattern, or if the pattern doesn't match the default one.
Calling from Kotlin
Here's an example of calling this method from Kotlin code:
val text = "[email protected]"
val pattern = """^[a-z]+@[a-z]+\.[a-z]+$"""
val emailAddress: EmailAddress? = EmailAddress.orNull(text, pattern)
assertNotNull(emailAddress)
This method is not available from Java code due to its non-explicit support for nullable types.
See the orThrow method for throwing an exception instead of returning null
in case of invalid text or pattern.