Skip to content

Commit 363ba27

Browse files
committed
Release 2.1.0
1 parent 5048fc1 commit 363ba27

File tree

3 files changed

+73
-27
lines changed

3 files changed

+73
-27
lines changed

CHANGELOG.md

Lines changed: 30 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
# Changelog
22

3-
## [2.0.2](https://github.com/seegno/validator.js-asserts/tree/2.0.2) (2016-04-07)
4-
[Full Changelog](https://github.com/seegno/validator.js-asserts/compare/2.0.1...2.0.2)
3+
## [v2.1.0](https://github.com/seegno/validator.js-asserts/tree/v2.1.0) (2016-04-10)
4+
[Full Changelog](https://github.com/seegno/validator.js-asserts/compare/v2.0.2...v2.1.0)
5+
6+
**Merged pull requests:**
7+
8+
- Add release instructions [\#96](https://github.com/seegno/validator.js-asserts/pull/96) ([ruimarinho](https://github.com/ruimarinho))
9+
- Add format option to date assert [\#95](https://github.com/seegno/validator.js-asserts/pull/95) ([franciscocardoso](https://github.com/franciscocardoso))
10+
11+
## [v2.0.2](https://github.com/seegno/validator.js-asserts/tree/v2.0.2) (2016-04-06)
12+
[Full Changelog](https://github.com/seegno/validator.js-asserts/compare/v2.0.1...v2.0.2)
513

614
**Implemented enhancements:**
715

@@ -13,8 +21,8 @@
1321
- Update dependencies [\#73](https://github.com/seegno/validator.js-asserts/pull/73) ([ruimarinho](https://github.com/ruimarinho))
1422
- Remove jscs inline camel case rules [\#65](https://github.com/seegno/validator.js-asserts/pull/65) ([nunofgs](https://github.com/nunofgs))
1523

16-
## [2.0.1](https://github.com/seegno/validator.js-asserts/tree/2.0.1) (2016-01-26)
17-
[Full Changelog](https://github.com/seegno/validator.js-asserts/compare/2.0.0...2.0.1)
24+
## [v2.0.1](https://github.com/seegno/validator.js-asserts/tree/v2.0.1) (2016-01-26)
25+
[Full Changelog](https://github.com/seegno/validator.js-asserts/compare/v2.0.0...v2.0.1)
1826

1927
**Fixed bugs:**
2028

@@ -24,8 +32,8 @@
2432

2533
- Add module exports [\#64](https://github.com/seegno/validator.js-asserts/pull/64) ([ruimarinho](https://github.com/ruimarinho))
2634

27-
## [2.0.0](https://github.com/seegno/validator.js-asserts/tree/2.0.0) (2016-01-21)
28-
[Full Changelog](https://github.com/seegno/validator.js-asserts/compare/1.1.0...2.0.0)
35+
## [v2.0.0](https://github.com/seegno/validator.js-asserts/tree/v2.0.0) (2016-01-21)
36+
[Full Changelog](https://github.com/seegno/validator.js-asserts/compare/v1.1.0...v2.0.0)
2937

3038
**Implemented enhancements:**
3139

@@ -56,8 +64,8 @@
5664
- Update should to version 8.1.1 🚀 [\#56](https://github.com/seegno/validator.js-asserts/pull/56) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot))
5765
- [email protected] breaks build 🚨 [\#39](https://github.com/seegno/validator.js-asserts/pull/39) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot))
5866

59-
## [1.1.0](https://github.com/seegno/validator.js-asserts/tree/1.1.0) (2015-10-16)
60-
[Full Changelog](https://github.com/seegno/validator.js-asserts/compare/1.0.0...1.1.0)
67+
## [v1.1.0](https://github.com/seegno/validator.js-asserts/tree/v1.1.0) (2015-10-16)
68+
[Full Changelog](https://github.com/seegno/validator.js-asserts/compare/v1.0.0...v1.1.0)
6169

6270
**Merged pull requests:**
6371

@@ -66,47 +74,47 @@
6674
- Add Bank Identifier Code assert [\#24](https://github.com/seegno/validator.js-asserts/pull/24) ([nunofgs](https://github.com/nunofgs))
6775
- Add International Bank Account Number assert [\#23](https://github.com/seegno/validator.js-asserts/pull/23) ([nunofgs](https://github.com/nunofgs))
6876

69-
## [1.0.0](https://github.com/seegno/validator.js-asserts/tree/1.0.0) (2015-08-11)
70-
[Full Changelog](https://github.com/seegno/validator.js-asserts/compare/0.0.7...1.0.0)
77+
## [v1.0.0](https://github.com/seegno/validator.js-asserts/tree/v1.0.0) (2015-08-11)
78+
[Full Changelog](https://github.com/seegno/validator.js-asserts/compare/v0.0.7...v1.0.0)
7179

7280
**Merged pull requests:**
7381

7482
- Refactor using ES6 [\#20](https://github.com/seegno/validator.js-asserts/pull/20) ([ruimarinho](https://github.com/ruimarinho))
7583
- Move dependencies to peer dependencies [\#19](https://github.com/seegno/validator.js-asserts/pull/19) ([ruimarinho](https://github.com/ruimarinho))
7684

77-
## [0.0.7](https://github.com/seegno/validator.js-asserts/tree/0.0.7) (2015-05-25)
78-
[Full Changelog](https://github.com/seegno/validator.js-asserts/compare/0.0.6...0.0.7)
85+
## [v0.0.7](https://github.com/seegno/validator.js-asserts/tree/v0.0.7) (2015-05-25)
86+
[Full Changelog](https://github.com/seegno/validator.js-asserts/compare/v0.0.6...v0.0.7)
7987

8088
**Merged pull requests:**
8189

8290
- Add null or date assert [\#17](https://github.com/seegno/validator.js-asserts/pull/17) ([nunofgs](https://github.com/nunofgs))
8391

84-
## [0.0.6](https://github.com/seegno/validator.js-asserts/tree/0.0.6) (2015-05-25)
85-
[Full Changelog](https://github.com/seegno/validator.js-asserts/compare/0.0.5...0.0.6)
92+
## [v0.0.6](https://github.com/seegno/validator.js-asserts/tree/v0.0.6) (2015-05-25)
93+
[Full Changelog](https://github.com/seegno/validator.js-asserts/compare/v0.0.5...v0.0.6)
8694

8795
**Merged pull requests:**
8896

8997
- Export object for validator.js extend method usage [\#16](https://github.com/seegno/validator.js-asserts/pull/16) ([ruimarinho](https://github.com/ruimarinho))
9098
- Add documentation for uri assert [\#15](https://github.com/seegno/validator.js-asserts/pull/15) ([ruimarinho](https://github.com/ruimarinho))
9199

92-
## [0.0.5](https://github.com/seegno/validator.js-asserts/tree/0.0.5) (2015-05-24)
93-
[Full Changelog](https://github.com/seegno/validator.js-asserts/compare/0.0.4...0.0.5)
100+
## [v0.0.5](https://github.com/seegno/validator.js-asserts/tree/v0.0.5) (2015-05-24)
101+
[Full Changelog](https://github.com/seegno/validator.js-asserts/compare/v0.0.4...v0.0.5)
94102

95103
**Merged pull requests:**
96104

97105
- Use travis container infrastructure [\#14](https://github.com/seegno/validator.js-asserts/pull/14) ([ruimarinho](https://github.com/ruimarinho))
98106
- Replace ISO 3166-1 country assert source [\#13](https://github.com/seegno/validator.js-asserts/pull/13) ([ruimarinho](https://github.com/ruimarinho))
99107
- Add URI assert [\#12](https://github.com/seegno/validator.js-asserts/pull/12) ([nunofgs](https://github.com/nunofgs))
100108

101-
## [0.0.4](https://github.com/seegno/validator.js-asserts/tree/0.0.4) (2015-01-16)
102-
[Full Changelog](https://github.com/seegno/validator.js-asserts/compare/0.0.3...0.0.4)
109+
## [v0.0.4](https://github.com/seegno/validator.js-asserts/tree/v0.0.4) (2015-01-16)
110+
[Full Changelog](https://github.com/seegno/validator.js-asserts/compare/v0.0.3...v0.0.4)
103111

104112
**Merged pull requests:**
105113

106114
- Update bignumber.js version [\#7](https://github.com/seegno/validator.js-asserts/pull/7) ([fixe](https://github.com/fixe))
107115

108-
## [0.0.3](https://github.com/seegno/validator.js-asserts/tree/0.0.3) (2014-12-01)
109-
[Full Changelog](https://github.com/seegno/validator.js-asserts/compare/0.0.2...0.0.3)
116+
## [v0.0.3](https://github.com/seegno/validator.js-asserts/tree/v0.0.3) (2014-12-01)
117+
[Full Changelog](https://github.com/seegno/validator.js-asserts/compare/v0.0.2...v0.0.3)
110118

111119
**Merged pull requests:**
112120

@@ -115,8 +123,8 @@
115123
- Remove extra console message from email test [\#4](https://github.com/seegno/validator.js-asserts/pull/4) ([ruimarinho](https://github.com/ruimarinho))
116124
- Add date diff less and greater than asserts [\#3](https://github.com/seegno/validator.js-asserts/pull/3) ([ruimarinho](https://github.com/ruimarinho))
117125

118-
## [0.0.2](https://github.com/seegno/validator.js-asserts/tree/0.0.2) (2014-11-26)
119-
[Full Changelog](https://github.com/seegno/validator.js-asserts/compare/0.0.1...0.0.2)
126+
## [v0.0.2](https://github.com/seegno/validator.js-asserts/tree/v0.0.2) (2014-11-26)
127+
[Full Changelog](https://github.com/seegno/validator.js-asserts/compare/v0.0.1...v0.0.2)
120128

121129
**Merged pull requests:**
122130

dist/asserts/date-assert.js

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,51 @@ exports.default = dateAssert;
77

88
var _validator = require('validator.js');
99

10+
var _lodash = require('lodash');
11+
1012
/**
1113
* Export `DateAssert`.
1214
*/
1315

16+
/**
17+
* Module dependencies.
18+
*/
19+
1420
function dateAssert() {
21+
var _ref = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
22+
23+
let format = _ref.format;
24+
1525
/**
1626
* Class name.
1727
*/
1828

1929
this.__class__ = 'Date';
2030

31+
/**
32+
* Optional peer dependency.
33+
*/
34+
35+
let moment;
36+
37+
/**
38+
* Validate format.
39+
*/
40+
41+
if (format) {
42+
if (!(0, _lodash.isString)(format)) {
43+
throw new Error(`Unsupported format ${ format } given`);
44+
}
45+
46+
moment = require('moment');
47+
}
48+
49+
/**
50+
* Format to match the input.
51+
*/
52+
53+
this.format = format;
54+
2155
/**
2256
* Validation algorithm.
2357
*/
@@ -31,13 +65,17 @@ function dateAssert() {
3165
throw new _validator.Violation(this, value);
3266
}
3367

68+
if (!this.format) {
69+
return true;
70+
}
71+
72+
if (!moment(value, this.format, true).isValid()) {
73+
throw new _validator.Violation(this, value);
74+
}
75+
3476
return true;
3577
};
3678

3779
return this;
3880
}
39-
/**
40-
* Module dependencies.
41-
*/
42-
4381
module.exports = exports['default'];

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "validator.js-asserts",
3-
"version": "2.0.2",
3+
"version": "2.1.0",
44
"description": "A set of extra asserts for validator.js.",
55
"license": "MIT",
66
"contributors": [

0 commit comments

Comments
 (0)