rsaenen / ngx-custom-validators

Angular custom directives for validation
129 stars 53 forks source link

Following URL is not valid: https://localhost:4200/xxx #29

Open bobKasbi opened 4 years ago

bobKasbi commented 4 years ago

Current behavior

When I add the following URL: https://localhost:4200/xxxxx in the text filed, the url is not valid.

Expected/desired behavior

This URL: https://localhost:4200/xxxxx should be valid and accepted by the validator

Environment information

Angular CLI: 8.3.8 Node: 12.13.0 OS: darwin x64 Angular: 8.2.14 NPM: 6.12.0 Typescript: 3.4.5

Other information

rsaenen commented 4 years ago

AFAIK, this is not a valid url.

It's an alias of a IP, it should has a domain to be valid.

bobKasbi commented 4 years ago

Yes, it's endpoint of an API. We use a form input text to pass it to BE. Is there an attribute or HTML5 data-attribute for the input text to allow such kind of URL, or something similar?

Example: <input type="text" [(ngModel)]="model.field" name="field" #field="ngModel" data-url="validate-api-endpoint" url>

or: <input type="text" [(ngModel)]="model.field" name="field" #field="ngModel" data-url="allow-api-endpoint" url>

bobKasbi commented 4 years ago

Any news here? Would be great if it's possible to add a kind of options such: https://github.com/validatorjs/validator.js

kktos commented 4 years ago

Ralf, I think if you allow any IP address, then localhost should be allowed too as it is a well known alias for 127.0.0.1.

Other the other sire, Bob, if you want, you can add in your /etc/hosts a FQDN with localhost as IP: e.g: www.bobkasbi.com 127.0.0.1 and use this "fake" FQDN in your code, rather than localhost.