Class: JWT::Claims::Numeric

Inherits:
Object
  • Object
show all
Defined in:
lib/jwt/claims/numeric.rb

Overview

The Numeric class is responsible for validating numeric claims in a JWT token. The numeric claims are: exp, iat and nbf

Defined Under Namespace

Classes: Compat

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.new(*args) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



30
31
32
33
34
35
# File 'lib/jwt/claims/numeric.rb', line 30

def self.new(*args)
  return super if args.empty?

  Deprecations.warning('Calling ::JWT::Claims::Numeric.new with the payload will be removed in the next major version of ruby-jwt')
  Compat.new(*args)
end

.verify!(payload:, **_args) ⇒ nil

Deprecated.

The ::JWT::Claims::Numeric.verify! method will be removed in the next major version of ruby-jwt

Verifies the numeric claims in the JWT payload.

Parameters:

  • payload (Hash)

    the JWT payload containing the claims.

  • _args (Hash)

    additional arguments (not used).

Returns:

  • (nil)

Raises:

  • (JWT::InvalidClaimError)

    if any numeric claim is invalid.



53
54
55
56
# File 'lib/jwt/claims/numeric.rb', line 53

def self.verify!(payload:, **_args)
  Deprecations.warning('The ::JWT::Claims::Numeric.verify! method will be removed in the next major version of ruby-jwt.')
  JWT::Claims.verify_payload!(payload, :numeric)
end

Instance Method Details

#verify!(context:) ⇒ nil

Verifies the numeric claims in the JWT context.

Parameters:

  • context (Object)

    the context containing the JWT payload.

Returns:

  • (nil)

Raises:

  • (JWT::InvalidClaimError)

    if any numeric claim is invalid.



42
43
44
# File 'lib/jwt/claims/numeric.rb', line 42

def verify!(context:)
  validate_numeric_claims(context.payload)
end