roshi 0.5.0 → 0.6.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: 619ef8d2899a55d75de84d88ac85bbe7eb3f4ad3
4
- data.tar.gz: 47ddfc446d64e0334ba3725da5347bd82b0485f2
3
+ metadata.gz: 814d31d3af87439532799132f8a92bb2637c6d22
4
+ data.tar.gz: 8f6ba713b9296d08fff2e69082b364fc216fe54d
5
5
  SHA512:
6
- metadata.gz: 7c9f1a79932a06bb913d26ff64892cc8f52e0bcb253b50269e5af03fb655f801fc3c3f57db85f2c5f95cd378a75395206e9d84c33edbfaf7aa92640379856a07
7
- data.tar.gz: 2b985a3248e924e490585022bdfe32a574486789f208d5f2e3a469d799b82a369197f1e0936dde7a20b689aa726925678175c72b08835cf73adc4420195d4b13
6
+ metadata.gz: b9aed1eae6d6acdd7a5c258580a1b4a8c0688a526a7417c6ed5734bcb78246b1c748f27386e6163491a4e2e3c1a316d262bd71fdf7769c3576384259dd38b3eb
7
+ data.tar.gz: 3aa7da2bd19d363356ff64ffe37ff5c42214047d28e67f7d6bc012fa648a9da0585c7dc5e2a7f86b859585f6411aca5243268b345696415fd896d58b27cb763e
data/README.md CHANGED
@@ -28,6 +28,7 @@ class TestModel
28
28
  validates :email, email: true
29
29
  validates :zip_code, zip_code: true # zip_code: { hiphenation: true }
30
30
  validates :phone_number, phone_number: true # phone_number: { hiphenation: true }
31
+ validates :date, date: true
31
32
  validates :hiragana, hiragana: true
32
33
  validates :version_number, version_number: true
33
34
  end
data/lib/roshi.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  require 'active_model'
2
2
  require 'roshi/version'
3
- %w(email zip_code phone_number hiragana version_number).each do |validator_name|
3
+ %w(email zip_code phone_number date hiragana version_number).each do |validator_name|
4
4
  require "roshi/active_model/validations/#{validator_name}_validator"
5
5
  end
@@ -0,0 +1,15 @@
1
+ require 'date'
2
+
3
+ module ActiveModel
4
+ module Validations
5
+ class DateValidator < EachValidator
6
+ def validate_each(record, attribute, value)
7
+ begin
8
+ Date.parse(value)
9
+ rescue
10
+ record.errors.add(attribute, options[:message] || I18n.t('errors.messages.invalid'))
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
data/lib/roshi/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Roshi
2
- VERSION = '0.5.0'
2
+ VERSION = '0.6.0'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: roshi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - kawahiro311
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-11-20 00:00:00.000000000 Z
12
+ date: 2015-11-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activemodel
@@ -96,6 +96,7 @@ files:
96
96
  - README.md
97
97
  - Rakefile
98
98
  - lib/roshi.rb
99
+ - lib/roshi/active_model/validations/date_validator.rb
99
100
  - lib/roshi/active_model/validations/email_validator.rb
100
101
  - lib/roshi/active_model/validations/hiragana_validator.rb
101
102
  - lib/roshi/active_model/validations/phone_number_validator.rb