Skip to content

Commit 4c63c7b

Browse files
author
Branko Vukelic
committed
Implemented isAfter validator that passes the test.
1 parent 0b2dd00 commit 4c63c7b

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

Diff for: lib/validator.js

+13
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,18 @@ Validator.prototype.isDate = function() {
225225
return this;
226226
}
227227

228+
Validator.prototype.isAfter = function(date) {
229+
date = date || new Date();
230+
var origDate = toDate(this.str);
231+
var compDate = toDate(date);
232+
233+
if (origDate && compDate && origDate < compDate) {
234+
return this.error(this.msg || 'Invalid date');
235+
}
236+
237+
return this;
238+
}
239+
228240
Validator.prototype.in = function(options) {
229241
if (options && typeof options.indexOf === 'function') {
230242
if (!~options.indexOf(this.str)) {
@@ -269,3 +281,4 @@ Validator.prototype.isArray = function() {
269281
}
270282
return this;
271283
}
284+

0 commit comments

Comments
 (0)