<commit_before># Security Identifiers

Security identifiers validation library for Ruby. 

Currently supports
• ISIN
• CUSIP

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::Validator.new('US0378331005')
    isin.valid? # => true

or

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

To validate a CUSIP

    cusip = SecurityIdentifiers::CUSIP::Validator.new('837649128')
    cusip.valid? # => true

## Rails

Includes custom validators for use in ActiveRecord

    class MyModel < ActiveRecord::Base
      validates :isin, isin: true
      validates :cusip, cusip: 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<commit_msg>update README for new syntax<commit_after># Security Identifiers

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

To fix a missing check digit

    isin = SecurityIdentifiers::ISIN.new('US037833100')
    isin.fix! 

Now you can validate

    isin.valid? # => true

The same method apply 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 MyModel < ActiveRecord::Base
      include SecurityIdentifiers::Validators
    
      validates :isin, isin: true
      validates :cusip, cusip: 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
{'fraction_non_alphanumeric': 0.08627156789197299, 'fraction_numerical': 0.028132033008252063, 'mean_word_length': 3.948051948051948, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2287937', 'n_tokens_mistral': 887, 'n_tokens_neox': 782, 'n_words': 285}