EmailValidator GetInstance Local?

时间:2016-08-10 14:43:17

标签: java apache-commons

很抱歉,如果问这个问题,请问。我搜索了但没有找到答案。

我对Apache EmailValidator有疑问。我想使用这个类来验证表单中的电子邮件,但我不明白这些方法之间的区别:

static EmailValidator   getInstance()

static EmailValidator   getInstance(boolean allowLocal)

此处有文档:https://commons.apache.org/proper/commons-validator/apidocs/index.html

我不确定但是什么意思,allowLocal

文档说:

  

本地地址是否应被视为有效?

但是什么是本地地址?

1 个答案:

答案 0 :(得分:0)

.localhost.localdomain结尾的地址。例如,admin@server1.localhostdave@mailserver.acme.localdomain。来自org/apache/commons/validator/routines/DomainValidator.java

// WARNING: this array MUST be sorted, otherwise it cannot be searched reliably using binary search
private static final String[] LOCAL_TLDS = new String[] {
   "localdomain",         // Also widely used as localhost.localdomain
   "localhost",           // RFC2606 defined
};