zendframework / zend-validator

Validator component from Zend Framework
BSD 3-Clause "New" or "Revised" License
181 stars 136 forks source link

Interface to add valid TLDs in Hostname validator #117

Open peterkeatingie opened 7 years ago

peterkeatingie commented 7 years ago

I recently used this validator but found it did not support .car TLD. The company I work for recently purchased such a domain and we needed to allow valid email addresses with that TLD.

I needed to extend the existing validator and also extend the EmailAddress validator to be able to reach the TLD list and then could attach the new validator in Apigility and add a list of TLDs, which were pushed onto the array in Hostname validator.

It would have been quite useful to just have a public function in Hostname validator to add to the validTlds array. That is what I am proposing to do myself.

adamlundrigan commented 7 years ago

There should be no need to extend the EmailAddress validator in this case; construct an instance of your extended Hostname validator and supply it to the EmailAddress instance through configuration option hostnameValidator or using the setHostnameValidator method.

Thanks to gTLDs the built-in TLD list falls out of sync with reality much more quickly than it used to when this validator was initially designed. As far as I'm aware there is no formalized process for keeping this list up-to-date; if there isn't it would be worthwhile to formulate one.

weierophinney commented 4 years ago

This repository has been closed and moved to laminas/laminas-validator; a new issue has been opened at https://github.com/laminas/laminas-validator/issues/23.