diff --git a/CHANGELOG.md b/CHANGELOG.md index 6facf57..03c717f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## [v2.3.0](https://github.com/seegno/validator.js-asserts/tree/v2.3.0) (2016-04-14) +[Full Changelog](https://github.com/seegno/validator.js-asserts/compare/v2.2.0...v2.3.0) + +**Implemented enhancements:** + +- Add Taxpayer Identification Number assert [\#66](https://github.com/seegno/validator.js-asserts/pull/66) ([nunofgs](https://github.com/nunofgs)) + ## [v2.2.0](https://github.com/seegno/validator.js-asserts/tree/v2.2.0) (2016-04-10) [Full Changelog](https://github.com/seegno/validator.js-asserts/compare/v2.1.0...v2.2.0) diff --git a/dist/asserts/taxpayer-identification-number-assert.js b/dist/asserts/taxpayer-identification-number-assert.js new file mode 100644 index 0000000..c40e15b --- /dev/null +++ b/dist/asserts/taxpayer-identification-number-assert.js @@ -0,0 +1,49 @@ +'use strict'; + +/** + * Module dependencies. + */ + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +exports.default = function () { + /** + * Optional peer dependency. + */ + + const tin = require('tin-validator'); + + /** + * Class name. + */ + + this.__class__ = 'TaxpayerIdentificationNumber'; + + /** + * Validation algorithm. + */ + + this.validate = function (value) { + if (typeof value !== 'string') { + throw new _validator.Violation(this, value, { value: _validator.Validator.errorCode.must_be_a_string }); + } + + if (!tin.isValid(value)) { + throw new _validator.Violation(this, value); + } + + return true; + }; + + return this; +}; + +var _validator = require('validator.js'); + +module.exports = exports['default']; + +/** + * Export `TaxpayerIdentificationNumberAssert`. + */ \ No newline at end of file diff --git a/dist/index.js b/dist/index.js index c629651..aac99e6 100644 --- a/dist/index.js +++ b/dist/index.js @@ -108,6 +108,10 @@ var _ukModulusCheckingAssert = require('./asserts/uk-modulus-checking-assert.js' var _ukModulusCheckingAssert2 = _interopRequireDefault(_ukModulusCheckingAssert); +var _taxpayerIdentificationNumberAssert = require('./asserts/taxpayer-identification-number-assert.js'); + +var _taxpayerIdentificationNumberAssert2 = _interopRequireDefault(_taxpayerIdentificationNumberAssert); + var _uriAssert = require('./asserts/uri-assert.js'); var _uriAssert2 = _interopRequireDefault(_uriAssert); @@ -126,10 +130,6 @@ var _uuidAssert2 = _interopRequireDefault(_uuidAssert); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } -/** - * Module dependencies. - */ - /** * Module dependencies. */ @@ -161,9 +161,14 @@ exports.default = { Phone: _phoneAssert2.default, PlainObject: _plainObjectAssert2.default, UkModulusChecking: _ukModulusCheckingAssert2.default, + TaxpayerIdentificationNumber: _taxpayerIdentificationNumberAssert2.default, Uri: _uriAssert2.default, UsSubdivision: _usSubdivisionAssert2.default, UsZipCode: _usZipCodeAssert2.default, Uuid: _uuidAssert2.default }; +/** + * Module dependencies. + */ + module.exports = exports['default']; \ No newline at end of file diff --git a/package.json b/package.json index 56cc60d..2c7de9a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "validator.js-asserts", - "version": "2.2.0", + "version": "2.3.0", "description": "A set of extra asserts for validator.js.", "license": "MIT", "contributors": [