Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make default validators compatible with new gTLDs by no longer validating TLDs against a whitelist #6

Merged
merged 17 commits into from
Jul 21, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
.PHONY : all clean validation.js
.PHONY : all clean

all: validation.min.js validation-ExtJS.min.js

validation.js: lib/validation.js.tpl lib/tld.js
node lib/tld.js > $@

validation.min.js: validation.js
validation.min.js:
./node_modules/.bin/uglifyjs -nc $< > $@

validation-ExtJS.min.js: validation-ExtJS.js
Expand Down
39 changes: 32 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
one-validation
==============
# one-validation

This is a collection of regular expressions for general validation purposes.
The basic design concept is to split up the regexes into semantic parts of the pattern to match.
As an example a url consists of many parts like scheme, optional userinfo, subdomain, domain, toplevel domain, path, query and fragment.
Expand All @@ -13,15 +13,40 @@ Package managers:
* npm: `npm install one-validation`
* bower: `bower install validation`

Supported patterns
==================
## Supported patterns

* domain
* subdomain
* email
* url

Building
========
## Examples

### domain and domainIdn

```
validation.domain.test('foo.co.uk');
return true;
```

```
validation.domainIdn.test('hällo-test.de');
return true;
```

### email and emailIdn

```
validation.email.test('[email protected]');
return true;
```

```
validation.domainIdn.test('test@hällo-test.de');
return true;
```

## Building

```
npm install
make
Expand Down
79 changes: 0 additions & 79 deletions lib/tld.js

This file was deleted.

150 changes: 0 additions & 150 deletions lib/validation.js.tpl

This file was deleted.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"devDependencies": {
"punycode": ">=0.2.0",
"uglify-js": "~1.3.4",
"vows": "=0.6.1"
"vows": "=0.7.0"
},
"scripts": {
"test": "vows",
Expand Down
17 changes: 11 additions & 6 deletions test/email-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,24 @@ function createBatch(name, shouldMatch, strings) {
vows
.describe('email validation')
.addBatch(createBatch('email', true, [
'[email protected]'
'[email protected]',
'[email protected]',
'[email protected]'
]))
.addBatch(createBatch('email', false, [
'[email protected]',
'foo@bar',
'foo@dk',
'[email protected]'
'foo@例子.测试',
'foo@उदाहरण.परीक्षा'
]))
.addBatch(createBatch('emailRelaxed', true, [
.addBatch(createBatch('emailIdn', true, [
'[email protected]',
'[email protected]',
'[email protected]',
'[email protected]'
'foo@例子.测试',
'foo.@उदाहरण.परीक्षा'
]))
.addBatch(createBatch('emailRelaxed', false, [
.addBatch(createBatch('emailIdn', false, [
'foo@bar',
'foo@dk'
]))
Expand Down
25 changes: 17 additions & 8 deletions test/url-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function createBatch(name, shouldMatch, strings) {

vows
.describe('url validation')
.addBatch(createBatch('url', true, [
.addBatch(createBatch('httpUrl', true, [
'http://www.foo.com/',
'http://www.foo.com/~username/',
'http://www.foo.com/?',
Expand Down Expand Up @@ -57,18 +57,20 @@ vows
// IP addresses for hostnames
'http://142.42.1.1/',
'http://142.42.1.1:8080/',
'http://223.255.255.254'
'http://223.255.255.254',
// New TLDs
'http://www.foo.cq/',
'http://www.foo.randomtld/',
// SLDs
'http://foo.co.uk',
'http://foo.org.uk'
]))
.addBatch(createBatch('url', false, [
.addBatch(createBatch('httpUrl', false, [
'http://localhost/',
'http://www.foo.cq/',
'@.foo.com/?',
'http://1.1.256.1',
'http://1.1.1.300'
]))
.addBatch(createBatch('httpUrlRelaxed', false, [
'http://localhost/'
]))
.addBatch(createBatch('httpUrlIdn', true, [
'http://✪df.ws/123',
'http://⌘.ws',
Expand All @@ -80,6 +82,13 @@ vows
]))
.addBatch(createBatch('httpUrlIdn', false, [
'http://foo.com/unicode_(✪)_in_parens',
'http://➡.ws/䨹'
'http://➡.ws/䨹',
'http://1.1.256.1',
'http://1.1.1.300'
]))
.addBatch(createBatch('domainIdn', false, [
'foo:bar.com',
'foo/bar.com',
'foo%bar.com'
]))
['export'](module);
Loading