validates the expiration option supplied
503519
def _clean_key_expiration_option(self):
        """"""
        allowed_entry = re.findall('^(\d+)(|w|m|y)$', self._expiration_time)
        if not allowed_entry:
            raise UsageError("Key expiration option: %s is not valid" % self._expiration_time)
104037
function validateOptions(options) {
  // Validate the schema
  try {
    //console.log(schemas.options);
    return doValidateAdd({
      parameterName: 'options',
      schema: schemas.options,
      newData: options,
      baseSchema: schemas.schema
    });
  } catch (err) {
    // @TODO Add test to see if it was a schema problem rather than options
    //console.log(err);
    if (err.extra && err.extra.parameterName.startsWith('options.schema')) {
      throw new errors.SchemaError(err.message, err.extra);
    }
    throw new errors.OptionsError(err.message, err.extra);
  }
}
290600
def setValidTo(self, value):
        

        valid_from = self.getValidFrom()
        valid_to = DateTime(value)
        interval = self.getExpirationInterval()

        if valid_from and interval:
            valid_to = valid_from + int(interval)
            self.getField("ValidTo").set(self, valid_to)
            logger.debug("Set ValidTo Date to: %r" % valid_to)
        else:
            # just set the value
            self.getField("ValidTo").set(self, valid_to)
1069155
function checkOptions(options) {
                // @TODO: should we throw an error if there are incorrect options provided?
                options = _.pick(options, permittedOptions);

                let validationErrors = utils.validateOptions(options);

                if (_.isEmpty(validationErrors)) {
                    return Promise.resolve(options);
                }

                // For now, we can only handle showing the first validation error
                return Promise.reject(validationErrors[0]);
            }
191308
public function isValid()
    {
        $payload = $this->getPayload();
        if (!isset($payload['exp'])) {
            return false;
        }

        $expireDateTime = DateTimeImmutable::createFromFormat('U', $payload['exp']);
        $now = new DateTime('now');
        return ($expireDateTime->getTimestamp() - $now->getTimestamp()) > 0;
    }
661241
function validate( opts, options ) {
	if ( !isObject( options ) ) {
		return new TypeError( 'invalid input argument. Options argument must be an object. Option: `' + options + '`.' );
	}
	if ( options.hasOwnProperty( 'flavor' ) ) {
		opts.flavor = options.flavor;
		if ( !isString( opts.flavor ) ) {
			return new TypeError( 'invalid option. Markdown flavor option must be a string primitive. Option: `' + opts.flavor + '`.' );
		}
	}
	return null;
}
119775
def validate_timeout_or_zero(option, value):
    
    if value is None:
        raise ConfigurationError("%s cannot be None" % (option, ))
    if value == 0 or value == "0":
        return 0
    return validate_positive_float(option, value) / 1000.0
1308028
def expires_at(self):
        """"""
        try:
            expires = min(sig.key_expiration for sig in itertools.chain(iter(uid.selfsig for uid in self.userids), self.self_signatures)
                          if sig.key_expiration is not None)

        except ValueError:
            return None

        else:
            return (self.created + expires)
740220
def valid_max_age(number):
    ""
    if isinstance(number, basestring):
        try:
            number = long(number)
        except (ValueError, TypeError):
            return False
    if number >= 0 and number % 1 == 0:
        return True
    return False
1281336
def expireat(self, key, when):
        """"""
        expire_time = datetime.fromtimestamp(when)
        key = self._encode(key)
        if key in self.redis:
            self.timeouts[key] = expire_time
            return True
        return False
1042632
def add_expiration_postfix(expiration):
    
    if re.match(r'^[1-9][0-9]*$', expiration):
        return expiration + ".0a1"

    if re.match(r'^[1-9][0-9]*\.0$', expiration):
        return expiration + "a1"

    return expiration
146758
def is_valid(self):
        
        if not isinstance(self._expiration, datetime.datetime):
            raise InvalidArgumentError('Expiration datetime must be specified.')

        if 'key' not in self.form_data:
            raise InvalidArgumentError('object key must be specified.')

        if 'bucket' not in self.form_data:
            raise InvalidArgumentError('bucket name must be specified.')
874141
def _validate_timeout(timeout, infinity_ok=False):
    
    if timeout is None:
        return

    if timeout == 'infinity':
        if infinity_ok:
            return
        else:
            raise ValueError(
                'timeout must be a positive integer '
                '("infinity" is not valid)')

    if isinstance(timeout, six.integer_types) and timeout > 0:
        return

    raise ValueError('timeout must be a positive integer')
1358114
function verifyExpiration() {
    if(opt.removeExpired === false) return;
    let items = thorin.util.readDirectory(rootPath, {
      ext: '.sess'
    });
    let calls = [],
      removes = 0,
      now = Date.now();
    items.forEach((fpath) => {
      calls.push((done) => {
        fse.readJson(fpath, (e, json) => {
          if(e) {
            logger.warn('Failed to lookup session file [%s] for cleaning.', fpath, e);
            return done();
          }
          if(now < json.e) return done();
          // remove the file.
          fse.remove(fpath, (e) => {
            if(e && e.code !== 'ENOENT') {
              logger.warn(`Failed to remove expired session file ${fpath}.`, e);
            } else {
              removes++;
            }
            return done();
          });
        });
      });
    });
    async.series(calls, () => {
      if(removes > 0) {
        logger.trace(`Removed ${removes} expired sessions.`);
      }
      setTimeout(verifyExpiration, CLEANUP_TIMER);
    });
  }
1258390
def validate_options(self, k, v):
        """"""

        super().validate_options(k, v)
        if k == 'delimiters':
            for d in v:
                if not isinstance(d, (dict, OrderedDict)):
                    raise ValueError("{}: 'delimters' entries must be of dict type.".format(self.__class__.__name__))
                for key, value in d.items():
                    if key not in ('open', 'close', 'content'):
                        raise KeyError(
                            "{}: '{}' is not a valid key for a 'delimeters' entry.".format(self.__class__.__name__, key)
                        )
                    if not isinstance(value, str):
                        raise ValueError(
                            "{}: 'delimeters' '{}' key should have str values.".format(self.__class__.__name__, value)
                        )
474183
def on_expiration(self, session, ese=None, session_key=None):
        
        super().on_expiration(session, ese, session_key)
        self.on_invalidation(session_key)
377351
def isExpired(certificate):
    
    if isinstance(certificate, six.string_types):
        certificate = json.loads(certificate)
    expiry = certificate.get('expiry', 0)
    return expiry < int(time.time() * 1000) + 20 * 60