Email Address Schema

The value has to an email address.

This is a specialization of the AnySchema the methods used there are used in the same way as in Any Schema:

  • title()
  • detail()
  • required()
  • forbidden()
  • default()
  • stripEmpty()
  • raw()

And the methods from String Schema:

  • makeString()
  • trim
  • replace()
  • lowerCase()
  • upperCase()
  • alphaNum
  • hex
  • allowControls
  • noHTML
  • stripDisallowed
  • min()
  • max()
  • length()
  • match()
  • notMatch()

And the methods from Domain Schema:

  • punycode()
  • resolve()

1. Checking

1.1. dns

The dns flag here will trigger a dns('MX') check on the domain part of the email address.

1.2. allow(list) / deny(list)

In principal this is identical to the any type and also valid(item) and invalid(item) may be used but the matching is a way complexer.

You can give complete email addresses, sub domains, domains or TLD in the list. The more precise element has precedence over the more general ones.

1.3. connect

In advance to the pure dns checking dns() this really connects to the server and checks so if a real mailserver is running under this domain. It will not validate the local part.

const schema = new EmailSchema().connect()
schema.connect(false) // to remove settings

1.4. blackList / greyList

In advance the mail server can be checked to not be on a

  • blacklist for abusive use
  • greylist for untrusted mail accounts
const schema = new EmailSchema()
.blackList() // check for black listed (Spammer)
.greyList()  // check for grey listed (One time accounts...)
schema.blackList(false).greyList(false) // to remove settings

2. Formatting

2.1. normalize

Extended formats like additional domains, sub domains and tags which mostly belong to the same mailbox will be removed.

const schema = new EmailSchema().normalize()
schema.normalize(false) // to remove settings

Beispiele:

2.2. withName

The email may also be in the form each mail program accepts using a descriptive name and the real address in <> brackets like: 'My Name [email protected]'. This is always possible but the resulting value will only contain the pure address if the withName() option is not set.

const schema = new EmailSchema().withName() // keep descriptive name
schema.withName(false) // to remove settings

results matching ""

    No results matching ""