README.md in active_validation-4.0.10 vs README.md in active_validation-4.0.11

- old
+ new

@@ -32,14 +32,16 @@ * [AlphaNumeric](#alphanumericvalidator) * [Base64](#base64validator) * [Boolean](#booleanvalidator) * [Coordinates](#coordinatesvalidator) * [Credit Card](#creditcardvalidator) +* [Csv](#csvvalidator) * [Currency](#currencyvalidator) * [CUSIP](#cusipvalidator) * [Email](#emailvalidator) * [Equality](#equalityvalidator) +* [FileSize](#filesizevalidator) * [Hex](#hexvalidator) * [IMEI](#imeivalidator) * [IP](#ipvalidator) * [ISBN](#isbnvalidator) * [ISIN](#isinvalidator) @@ -307,10 +309,44 @@ it { should ensure_valid_credit_card_format_of(:cc_number) } it { should_not ensure_valid_credit_card_format_of(:name) } end ``` +## CsvValidator + +Options: :columns :columns_in, :columns_less_than, :columns_less_than_or_equal_to, + :columns_greater_than, :columns_greater_than_or_equal_to, :rows, :rows_in, :rows_less_than, + :rows_less_than_or_equal_to, :rows_greater_than, :rows_greater_than_or_equal_to + +With an ActiveRecord model: + +```ruby +class Product < ActiveRecord::Base + attr_accessor :csv, :name + validates :csv, csv: { columns: 6, rows_less_than: 20 } +end +``` + +Or any ruby class: + +```ruby +class Product + include ActiveModel::Validations + attr_accessor :csv, :name + validates :csv, csv: { columns_less_than: 6, rows: 20 } +end +``` + +RSpec matcher is also available for your convenience: + +```ruby +describe Product do + it { should ensure_valid_csv_format_of(:csv) } + it { should_not ensure_valid_csv_format_of(:name) } +end +``` + ## CurrencyValidator **Ex:** 123.00 or .1 **Rules:** @@ -392,14 +428,14 @@ ## EmailValidator **Ex:** user@example.com or user+123@example-site.com **Rules:** - * Characters in username: a-z 0-9 -_+. + * Characters in username: a-z 0-9 -.+_ * Must include: @ * Characters in domain: a-z 0-9 - - * Must include extension: .co, .org, .museum + * Must include extension: .com, .org, .museum With an ActiveRecord model: ```ruby class User < ActiveRecord::Base @@ -472,9 +508,41 @@ ```ruby describe Auction do it { should ensure_equality_of(:bid).to(:price) } it { should_not ensure_equality_of(:bid).to(:product) } +end +``` + +## FileSizeValidator + +Options: :in, :less_than, :less_than_or_equal_to, :greater_than, :greater_than_or_equal_to + +With an ActiveRecord model: + +```ruby +class Product < ActiveRecord::Base + attr_accessor :file, :name + validates :file, file_size: { in: 5.megabytes..10.megabytes } +end +``` + +Or any ruby class: + +```ruby +class Product + include ActiveModel::Validations + attr_accessor :file, :name + validates :file, file_size: { in: 5.megabytes..10.megabytes } +end +``` + +RSpec matcher is also available for your convenience: + +```ruby +describe Product do + it { should ensure_valid_csv_format_of(:file) } + it { should_not ensure_valid_csv_format_of(:name) } end ``` ## HexValidator