Forked from sashazykov/bitcoin_address_validator.rb
Last active
January 2, 2016 19:09
-
-
Save christiangenco/8348162 to your computer and use it in GitHub Desktop.
Simple Rails bitcoin address validation. Doesn't calculate the checksum or anything fancy - just checks that the address starts with a 1 or 3, consists only of alphanumeric characters, and is 27-34 characters long (from https://en.bitcoin.it/wiki/Address).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class User < ActiveRecord::Base | |
validates :bitcoin_address, format: { with: /\A(1|3)[a-zA-Z1-9]{26,33}\z/, | |
message: "invalid bitcoin address" } | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment