roshi 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 74ae3345f44abe7cb6653346f6a44d5ee49eb9ec
4
- data.tar.gz: 3e61988351fae142c14c9a1ba37d304693aeee45
3
+ metadata.gz: 89c1e7b7039c5e2ed89afcdc0f77456810045450
4
+ data.tar.gz: 3c35070c49f8282a08f142ceb43bd7b03d833f44
5
5
  SHA512:
6
- metadata.gz: 848cb6627fb96310ad6f542031ad3a8a120a1b6d56926e92a668f8cd361f06b528b9959319d88885f4ebe98fa3fc9720ef459bb686d55d84914c00fb740d25d5
7
- data.tar.gz: 9eade08381849034064d1829b278580ba968e91f308c4b12fd2ba7a451861e9ea410c21f4456ecbf6465742c8d04ab4e0a53e00c1f877f4b080b8c821a20a1d6
6
+ metadata.gz: a147b67ee8260f0e806fb3ea096ccc6b077625136cc6f7b7a84618dd198456c5b1b480ba9cac6a75af82ffa10776b426150ad00db46bcc7efdd8bb7d5b7eaba6
7
+ data.tar.gz: e88ad951639b8eb8062720614d8069eb25ab7977e4b44699be352b3606509a6dec898328da73bfe0c97a8f929bc3cf3bd5725b75d80d00760e87f4447e928cd1
data/README.md CHANGED
@@ -26,6 +26,7 @@ Or install it yourself as:
26
26
  ```ruby
27
27
  class TestModel
28
28
  validates :email, email: true
29
+ validates :zip_code, zip_code: true
29
30
  validates :version_number, version_number: true
30
31
  end
31
32
  ```
data/lib/roshi.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  require 'active_model'
2
2
  require 'roshi/version'
3
- %w(email version_number).each do |validator_name|
3
+ %w(email zip_code version_number).each do |validator_name|
4
4
  require "roshi/active_model/validations/#{validator_name}_validator"
5
5
  end
@@ -0,0 +1,11 @@
1
+ module ActiveModel
2
+ module Validations
3
+ class ZipCodeValidator < EachValidator
4
+ def validate_each(record, attribute, value)
5
+ unless value =~ /\A\d{3}\-?\d{4}\z/i
6
+ record.errors.add(attribute, options[:message] || I18n.t('errors.messages.invalid'))
7
+ end
8
+ end
9
+ end
10
+ end
11
+ end
data/lib/roshi/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Roshi
2
- VERSION = '0.2.0'
2
+ VERSION = '0.3.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: roshi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - kawahiro311
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-05 00:00:00.000000000 Z
11
+ date: 2015-11-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -96,6 +96,7 @@ files:
96
96
  - lib/roshi.rb
97
97
  - lib/roshi/active_model/validations/email_validator.rb
98
98
  - lib/roshi/active_model/validations/version_number_validator.rb
99
+ - lib/roshi/active_model/validations/zip_code_validator.rb
99
100
  - lib/roshi/version.rb
100
101
  - roshi.gemspec
101
102
  homepage: https://github.com/fusic/roshi