tv4-formats
Advanced tools
Comparing version 2.0.0 to 2.1.0
@@ -9,3 +9,5 @@ (function () { | ||
durationRegExp = require('./src/durationRegExp'), | ||
dateRegExp = /^[0-9]{4,}-[0-9]{2}-[0-9]{2}$/; | ||
dateRegExp = /^[0-9]{4,}-[0-9]{2}-[0-9]{2}$/, | ||
guidRegExp = | ||
/^\{?[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}\}?$/; | ||
@@ -75,2 +77,6 @@ try { | ||
}; | ||
exports.guid = function (value) { | ||
return guidRegExp.test(value) ? null : 'A valid GUID is expected'; | ||
}; | ||
}()); |
{ | ||
"name": "tv4-formats", | ||
"version": "2.0.0", | ||
"version": "2.1.0", | ||
"description": "Common JSON Schema string format constraints in the form of tv4 validator callbacks", | ||
@@ -27,5 +27,5 @@ "main": "index.js", | ||
"homepage": "https://github.com/ikr/tv4-formats", | ||
"engine": "node >= 0.8", | ||
"engine": "node >= 0.10", | ||
"devDependencies": { | ||
"jscs": "^2.3.5", | ||
"jscs": "^3.0.3", | ||
"jshint": "^2.8.0", | ||
@@ -36,4 +36,4 @@ "mocha": "^2.3.3" | ||
"moment": "^2.10.6", | ||
"validator": "^4.2.0" | ||
"validator": "^5.2.0" | ||
} | ||
} |
@@ -5,3 +5,3 @@ [![Build Status](https://travis-ci.org/ikr/tv4-formats.svg?branch=master)](https://travis-ci.org/ikr/tv4-formats) | ||
Provides the implementation of common [JSON Schema](http://json-schema.org/) string format | ||
Provides an implementation of common [JSON Schema](http://json-schema.org/) string format | ||
constraints in the form of | ||
@@ -37,8 +37,9 @@ [tv4 validator callbacks.](https://github.com/geraintluff/tv4#addformatformat-validationfunction) | ||
* credit-card-number | ||
* date (YYYY-MM-DD) | ||
* date-time (for example, 2014-05-02T12:59:29+00:00) | ||
* [duration](http://en.wikipedia.org/wiki/Iso8601#Durations) (for example, P1DT12H for 1.5 days) | ||
* [guid](https://en.wikipedia.org/wiki/Globally_unique_identifier) | ||
* uri | ||
* url | ||
* credit-card-number | ||
* [duration](http://en.wikipedia.org/wiki/Iso8601#Durations) (for example, P1DT12H for 1.5 days) |
@@ -177,2 +177,24 @@ describe('tv4-formats', function () { | ||
}); | ||
describe('guid', function () { | ||
it('is defined', function () { | ||
assert.strictEqual(typeof formats.guid, 'function'); | ||
}); | ||
it('validates positively', function () { | ||
assert.strictEqual(formats.guid('34f8216d-b4b2-5d4d-b46b-ba1466ea3ab9'), null); | ||
}); | ||
it('validates negatively 1', function () { | ||
assert(formats.guid('34f8216d-xxxx-5d4d-b46b-ba1466ea3ab9').length > 0); | ||
}); | ||
it('validates negatively 2', function () { | ||
assert(formats.guid('ikr@ikr.su').length > 0); | ||
}); | ||
it('accepts optional curlies', function () { | ||
assert.strictEqual(formats.guid('{7e39b1e6-23d1-11e6-8456-e75e8e0d2af6}'), null); | ||
}); | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
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
25834
279
44
+ Addedvalidator@5.7.0(transitive)
- Removeddepd@1.1.0(transitive)
- Removedvalidator@4.9.0(transitive)
Updatedvalidator@^5.2.0