Skip to content

deg84/isbn_validation

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

IsbnValidation

Custom ActiveRecord Validation for International Standard Book Number (ISBN) fields. Supports both ISBN-10 and ISBN-13. Will guarantee that validated fields contain valid ISBNs.

Default behaviour is to allow either ISBN-10 or ISBN-13, but this can be altered by specifying the :with option as shown in the example below.

For more information on ISBN, see http://en.wikipedia.org/wiki/Isbn

Installation

To use it, add it to your Gemfile:

gem 'isbn_validation'

The current version of isbn_validation only supports Rails 3. For Rails 2.x support, please use v0.1.2.

Example

class Book < ActiveRecord::Base
  validates :isbn,   :isbn_format => true
  validates :isbn10, :isbn_format => { :with => :isbn10 }
  validates :isbn13, :isbn_format => { :with => :isbn13 }
end

Contributors

  • Nick Plante
  • Omer Jakobinsky - Rails 3.0 compatibility

Copyright © 2011 Nick Plante, released under the MIT license

About

ISBN Validation for ActiveRecord Models

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Ruby 100.0%