tv4-formats
Advanced tools
Comparing version 0.1.0 to 0.2.0
@@ -41,2 +41,10 @@ (function () { | ||
}; | ||
exports['credit-card-number'] = function (value) { | ||
if (validator.isCreditCard(value)) { | ||
return null; | ||
} | ||
return 'A valid credit card number format expected'; | ||
}; | ||
}()); |
{ | ||
"name": "tv4-formats", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"description": "Common JSON Schema string format constraints in the form of tv4 validator callbacks", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -0,1 +1,3 @@ | ||
[![Build Status](https://secure.travis-ci.org/ikr/tv4-formats.png)](http://travis-ci.org/ikr/tv4-formats) | ||
# About | ||
@@ -36,1 +38,2 @@ | ||
* uri | ||
* credit-card-number |
@@ -75,5 +75,23 @@ describe('tv4-formats', function () { | ||
it('validates negatively', function () { | ||
assert(formats.email('+41 43 000 00 00').length > 0); | ||
assert(formats.uri('+41 43 000 00 00').length > 0); | ||
}); | ||
}); | ||
describe('credit-card-number', function () { | ||
it('is defined', function () { | ||
assert.strictEqual(typeof formats['credit-card-number'], 'function'); | ||
}); | ||
it('validates positively', function () { | ||
assert.strictEqual(formats['credit-card-number']('4242424242424242'), null); | ||
}); | ||
it('validates negatively on garbage', function () { | ||
assert(formats['credit-card-number']('MA CC NUM').length > 0); | ||
}); | ||
it('validates negatively on a number violating the checksum', function () { | ||
assert(formats['credit-card-number']('1000000000000000').length > 0); | ||
}); | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
15209
8
113
39