Third parameter for FORM::URL validation rule for tld

6 years ago

Grelek
Member | 235
+
0
-

Hello,

I think it could be useful feature. Normally FORM::URL marks URLs without tld as valid. I want to add third parameter (TRUE) that describes if we want “tld mode”, if not, leave third parameter blank.

addRule(FORM::URL, "Non-valid URL!"); // accepts www.bbc
addRule(FORM::URL, "Non-valid URL!", TRUE); // accepts only www.bbc.tld

// and the same with emails

BTW – sorry for my errors in english

Last edited by Grelek (2013-05-12 19:14)

6 years ago

Majkl578
Moderator | 1379
+
0
-

How would you identify (distinguish) TLD?

6 years ago

Grelek
Member | 235
+
0
-

I don't understand question. TLD can be distinguished with regular expression. If you mean how would I identify TLD (com, cz, net…), TLD can be pulled up from URL and compared with array of TLDs.

6 years ago

Majkl578
Moderator | 1379
+
0
-

array of TLDs

The problem is, there is no such array of TLDs, because TLDs are expanding, everyone can buy his own gTLD. See ICANN: http://newgtlds.icann.org/en/. So it can't be safely matched against some list, because this list is being extended every day.

6 years ago

Grelek
Member | 235
+
0
-

Ah. So it could be just checking, if any TLD exists, but it looks kind of useless.

6 years ago

Jan Tvrdík
Nette guru | 2553
+
0
-

Normally FORM::URL marks URLs without tld as valid.

Not true, in case of www.bbc is bbc the TLD.

6 years ago

Grelek
Member | 235
+
0
-

Jan Tvrdík wrote:

Normally FORM::URL marks URLs without tld as valid.

Not true, in case of www.bbc is bbc the TLD.

Oops, now I see it. But I meant that FORM::URL can identify TLDs. But now I see the problems, why it isn't implemented.