No commit activity in last 3 years
No release in over 3 years
Validate ISIN, CUSIP and SEDOL codes
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

~> 1.3
= 2.12.1
>= 12.0.0, ~> 12.0
>= 3.5.0, ~> 3.5
= 0.47.1
 Project Readme

Security Identifiers

Build Status Code Climate Dependency Status Gem Version

Security identifiers validation library for Ruby.

Currently supports

  • ISIN
  • CUSIP
  • SEDOL

Validates:

  • Format
  • Check Digit

Installation

Add this line to your application's Gemfile:

gem 'security_identifiers'

And then execute:

$ bundle

Or install it yourself as:

$ gem install security_identifiers

Usage

To validate an ISIN

isin = SecurityIdentifiers::ISIN.new('US0378331005')
isin.valid? # => true

or with an invalid identifier

isin = SecurityIdentifiers::ISIN.new('S0378331005') # => raises SecurityIdentifiers::InvalidFormat

Now you can validate

isin.valid? # => true

The same method applies to CUSIPs and SEDOLs.

CUSIPs and SEDOLs also support converting these identifiers to ISINs.

cusip = SecurityIdentifiers::CUSIP.new('125509BG3')
cusip.to_isin('US') # => SecurityIdentifiers::ISIN

ActiveModel Validations

Includes custom validators for use in ActiveModel/ActiveRecord

class Security
  include ActiveModel::Validations
  include SecurityIdentifiers::Validations

  attr_accessor :cusip, :isin, :sedol

  def initialize(options = {})
    @cusip = options[:cusip]
    @isin  = options[:isin]
    @sedol = options[:sedol]
  end

  validates :cusip, cusip: true, allow_blank: true
  validates :isin,  isin:  true, allow_blank: true
  validates :sedol, sedol: true, allow_blank: true
end

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request