index.js
function (validator, options) {
    var when = options.default;
    var fn = function (context, config) {
      if ((when === config.context.operation) ||
          (when === 'update' && ['create', 'update'].indexOf(config.context.operation) > -1)
      ) {
        return new Date().toISOString();
      }
      return undef;
    };
    fn.isJoi = true;
    return validator.default(fn);
  }
function (validator, options) {
    var when = options.default;
    var fn = function (context, config) {
      if ((when === config.context.operation) ||
          (when === 'update' && ['create', 'update'].indexOf(config.context.operation) > -1)
      ) {
        return new Date().toISOString();
      }
      return undef;
    };
    fn.isJoi = true;
    return validator.default(fn);
  }
function ( validator , options ) { var when = options . default ; var fn = function ( context , config ) { if ( ( when === config . context . operation ) || ( when === 'update' && [ 'create' , 'update' ] . indexOf ( config . context . operation ) > - 1 ) ) { return new Date ( ) . toISOString ( ) ; } return undef ; } ; fn . isJoi = true ; return validator . default ( fn ) ; }
Set a default date based on the contextual operation in which the joi object is being validated.

If 'update' is the specified default, default the value on both 'update' && 'create' operations
otherwise only default if the operation matches the specified default.

@param {Joi} validator - the object that is having a default set
@param {DefaultSpecifierOptions} options - the options for setting the default
@param {String} options.default - [create, update]
@returns {Joi} - the new validator
Set a default date based on the contextual operation in which the joi object is being validated .