Email

Other than regular string, raw string, and open string, a string can be passed as an Internet email as it is predefined in the parser. The email format is derived from the HTML 5.1-Forms Email syntax recommended by W3C. Internet Object Email Format does not follow the RFC-5322 email representation as it is too strict to implement for the users.

Email format follows the syntax specified in the HTML 5.1 W3C recommendation under section 4.10.5.1.5.

The code snippet shows how to define an email-id in the Internet Object Document.

# Defining an Email
userEmail: email
---
[email protected]
# Using  derived type email to pass email Information  
Subject: {
         string, 
         From: string, 
         To: string, senderEmail: email, 
         reciverEmail: email
         }
---
{    
     An official Email, 
     John Doe, Alex Wick, 
     [email protected],
     [email protected]
}

MemberDef

The Email is derived from the String type, hence it shares the same MemberDef as the String. However, Email enforces additional constraints with the respective email format.

Choices

The choices can be added to member variables in the email so that it is restricted to the fixed set of available choices. Choices must be an array of valid emails. Here, the snippet shows how to add choices for the string subtype email.

# Assign choices for a companyEmail.  
companyEmail: {
  type: email, 
  choices: [[email protected], [email protected], 
              [email protected], [email protected]]
}
---
[email protected]

pattern

User may specify pattern for the email by defining pattern as shown in the snippet below.

# Set pattern for referenceEmail with type email.
referenceEmail: {
  type: email , 
  pattern: '[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,}$'
 }
---
~ [email protected]
~ [email protected]

Last updated