0.01
Low commit activity in last 3 years
No release in over a year
Social Security Number (SSN) Validation
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

 Project Readme

SsnValidation

SsnValidation is a very basic ruby gem that can validate a US Social Security Number (SSN) or ITIN. It returns a hash of error keys/messages that can be used within ActiveRecord errors or otherwise to ensure syntactically valid SSNs.

Installation

Add this line to your application's Gemfile:

gem 'ssn_validation'

And then execute:

$ bundle

Or install it yourself as:

$ gem install ssn_validation

Usage

❯ irb
> require 'ssn_validation'
> SsnValidation::Ssn.validate('abc')
=> {:nine_digits=>"SSN value is not 9 digits", :non_digits=>"SSN value contains non-digits"}
> SsnValidation::Ssn.validate(123006789)
=> {:zero_group=>"SSN value contains zeros in group number xxx-00-xxxx"}
> SsnValidation::Ssn.validate(nil)
=> {:nine_digits=>"SSN value is not 9 digits"}
> SsnValidation::Ssn.validate('')
=> {:nine_digits=>"SSN value is not 9 digits"}

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/johnsinco/ssn_validation

License

The gem is available as open source under the terms of the MIT License.