dist/vacationApproval/node-business-rules.js
function (args) {
                args.HasError = false;
                args.ErrorMessage = "";

                //no dates - > nothing to validate
                if (!_.isDate(this.From) || !_.isDate(this.To))
                    return;

                if (self.FromDatePart.isAfter(self.ToDatePart)) {
                    args.HasError = true;
                    args.ErrorMessage = customErrorMessage({ Msg: "Date from '{From}' must be before date to '{To}'.", Format: 'MM/DD/YYYY' }, this);
                    args.TranslateArgs = { TranslateId: 'BeforeDate', MessageArgs: this, CustomMessage: customErrorMessage };
                    return;
                }

                var minDays = 1;
                var maxDays = 25;

                //maximal duration
                if (self.IsOverLimitRange || (self.VacationDaysCount > maxDays || self.VacationDaysCount < minDays)) {
                    args.HasError = true;
                    var messageArgs = { MaxDays: maxDays, MinDays: minDays };
                    args.ErrorMessage = Utils.StringFce.format("Vacation duration value must be between {MinDays] and {MaxDays} days.", messageArgs);
                    args.TranslateArgs = { TranslateId: 'RangeDuration', MessageArgs: messageArgs };
                    return;
                }

                var diff = _.difference(self.ExcludedDaysDatePart, self.RangeDays);
                if (diff.length != 0) {
                    args.HasError = true;
                    var messageArgs2 = { ExcludedDates: _.reduce(diff, function (memo, item) {
                            return memo + item.format("MM/DD/YYYY");
                        }) };
                    args.ErrorMessage = Utils.StringFce.format("Excluded days are not in range. '{ExcludedDates}'.", messageArgs2);
                    args.TranslateArgs = { TranslateId: 'ExcludedDaysMsg', MessageArgs: messageArgs2 };
                    return;
                }
            }
function (args) {
                args.HasError = false;
                args.ErrorMessage = "";

                //no dates - > nothing to validate
                if (!_.isDate(this.From) || !_.isDate(this.To))
                    return;

                if (self.FromDatePart.isAfter(self.ToDatePart)) {
                    args.HasError = true;
                    args.ErrorMessage = customErrorMessage({ Msg: "Date from '{From}' must be before date to '{To}'.", Format: 'MM/DD/YYYY' }, this);
                    args.TranslateArgs = { TranslateId: 'BeforeDate', MessageArgs: this, CustomMessage: customErrorMessage };
                    return;
                }

                var minDays = 1;
                var maxDays = 25;

                //maximal duration
                if (self.IsOverLimitRange || (self.VacationDaysCount > maxDays || self.VacationDaysCount < minDays)) {
                    args.HasError = true;
                    var messageArgs = { MaxDays: maxDays, MinDays: minDays };
                    args.ErrorMessage = Utils.StringFce.format("Vacation duration value must be between {MinDays] and {MaxDays} days.", messageArgs);
                    args.TranslateArgs = { TranslateId: 'RangeDuration', MessageArgs: messageArgs };
                    return;
                }

                var diff = _.difference(self.ExcludedDaysDatePart, self.RangeDays);
                if (diff.length != 0) {
                    args.HasError = true;
                    var messageArgs2 = { ExcludedDates: _.reduce(diff, function (memo, item) {
                            return memo + item.format("MM/DD/YYYY");
                        }) };
                    args.ErrorMessage = Utils.StringFce.format("Excluded days are not in range. '{ExcludedDates}'.", messageArgs2);
                    args.TranslateArgs = { TranslateId: 'ExcludedDaysMsg', MessageArgs: messageArgs2 };
                    return;
                }
            }
function ( args ) { args . HasError = false ; args . ErrorMessage = "" ; //no dates - > nothing to validate if ( ! _ . isDate ( this . From ) || ! _ . isDate ( this . To ) ) return ; if ( self . FromDatePart . isAfter ( self . ToDatePart ) ) { args . HasError = true ; args . ErrorMessage = customErrorMessage ( { Msg : "Date from '{From}' must be before date to '{To}'." , Format : 'MM/DD/YYYY' } , this ) ; args . TranslateArgs = { TranslateId : 'BeforeDate' , MessageArgs : this , CustomMessage : customErrorMessage } ; return ; } var minDays = 1 ; var maxDays = 25 ; //maximal duration if ( self . IsOverLimitRange || ( self . VacationDaysCount > maxDays || self . VacationDaysCount < minDays ) ) { args . HasError = true ; var messageArgs = { MaxDays : maxDays , MinDays : minDays } ; args . ErrorMessage = Utils . StringFce . format ( "Vacation duration value must be between {MinDays] and {MaxDays} days." , messageArgs ) ; args . TranslateArgs = { TranslateId : 'RangeDuration' , MessageArgs : messageArgs } ; return ; } var diff = _ . difference ( self . ExcludedDaysDatePart , self . RangeDays ) ; if ( diff . length != 0 ) { args . HasError = true ; var messageArgs2 = { ExcludedDates : _ . reduce ( diff , function ( memo , item ) { return memo + item . format ( "MM/DD/YYYY" ) ; } ) } ; args . ErrorMessage = Utils . StringFce . format ( "Excluded days are not in range. '{ExcludedDates}'." , messageArgs2 ) ; args . TranslateArgs = { TranslateId : 'ExcludedDaysMsg' , MessageArgs : messageArgs2 } ; return ; } }
create validator function
create validator function