Validate a string attribute in Base64 manner
Ruby
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
config/locales
lib
spec
.coverrails.yml
.gitignore
.travis.yml
Gemfile
README.md
Rakefile
activemodel-base64_validator.gemspec

README.md

activemodel-base64_validator

Build Status Code Climate Coverage Status Dependency Status

Usage

Add to your Gemfile:

gem 'activemodel-base64_validator'

Run:

bundle install

Then add the following to your model:

validates :my_base64_attribute, base64: true

Validation outside a model

If you need to validate a base64 outside a model, you can get the regexp:

Base64Validator::REGEXP
Base64Validator.valid?(string)  # true or false

Credit

Regular Expression based on http://stackoverflow.com/a/475217/1297336