'use strict';

var moment = require('moment');
var NOW = 'now';

exports = module.exports = {
  validator: function (val, ruleObj) {
    if (!val) {
      return true;
    }

    var date;
    var dateInputFormat = ruleObj.params[0];
    var dateInput = moment(val, dateInputFormat);

    if (ruleObj.params[1].toLowerCase() === NOW) {
      date = moment();
    } else {
      date = moment(ruleObj.params[1], dateInputFormat);
    }

    return dateInput.isAfter(date, 'day');
  },
  message: '<%= propertyName %> must greater than <%= ruleParams[1] %>.'
};


@@ -8,16 +8,43 @@
 rict';%0A%0A
+var _ = require('lodash');%0A
 var mome
@@ -83,16 +83,362 @@
 = 'now';
+%0Avar message = '%3C%25= propertyName %25%3E must greater than %3C%25= ruleParams%5B1%5D %25%3E.';%0Avar self = exports;%0A%0A// Use object (it will be passed as reference at index.js) to represent the message,%0A// because we want to change it dynamically based on the offset parameter%0A// based on the offset parameters.%0Avar messageObj = %7B%0A  toString: _.constant(message)%0A%7D;
 %0A%0Aexport
@@ -649,16 +649,60 @@
 Format);
+%0A    var offset = Number(ruleObj.params%5B2%5D);
 %0A%0A    if
@@ -854,63 +854,398 @@
     
-return dateInput.isAfter(date
+messageObj.toString = _.constant(message);%0A%0A    if (offset) %7B%0A      if (offset %3C 0) %7B%0A        offset = Math.abs(offset);%0A        messageObj.toString = _.constant(%0A          '%3C%25= propertyName %25%3E must greater than %3C%25= ruleParams%5B1%5D %25%3E minus %3C%25= Math.abs(ruleParams%5B2%5D) %25%3E days.'%0A        );%0A        date = date.subtract(offset
 , 'day
+s
 ');%0A  
-%7D,%0A  message: 
+    %7D else %7B%0A        messageObj.toString = _.constant(
 '%3C%25=
@@ -1299,15 +1299,174 @@
 ms%5B1%5D %25%3E
-.'
+ plus %3C%25= ruleParams%5B2%5D %25%3E days.');%0A        date = date.add(offset, 'days');%0A      %7D%0A    %7D%0A%0A    return dateInput.isAfter(date, 'day');%0A  %7D,%0A  message: messageObj
 %0A%7D;%0A%0A

Implement relative parameter for date-after validation rule