webauthn_credential.rb 803 B

12345678910111213141516171819202122
  1. # frozen_string_literal: true
  2. # == Schema Information
  3. #
  4. # Table name: webauthn_credentials
  5. #
  6. # id :bigint(8) not null, primary key
  7. # external_id :string not null
  8. # public_key :string not null
  9. # nickname :string not null
  10. # sign_count :bigint(8) default(0), not null
  11. # user_id :bigint(8)
  12. # created_at :datetime not null
  13. # updated_at :datetime not null
  14. #
  15. class WebauthnCredential < ApplicationRecord
  16. validates :external_id, :public_key, :nickname, :sign_count, presence: true
  17. validates :external_id, uniqueness: true
  18. validates :nickname, uniqueness: { scope: :user_id }
  19. validates :sign_count,
  20. numericality: { only_integer: true, greater_than_or_equal_to: 0, less_than_or_equal_to: 2**63 - 1 }
  21. end