roshi 0.8.2 → 0.8.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6a6f3d2ba408df338768dddc5c023ce93b26e17cee8edc977f1035f5cfa1dc47
4
- data.tar.gz: 49a159c70ecfa3f2ae4551cd6f4a9adee8cb4e7bdf1737947e045a1713dc9c84
3
+ metadata.gz: 941c355a142a261c61928481ee8a1ebeceecce89d37f2491168b15c975369411
4
+ data.tar.gz: b3214c0160dc30074bb7fe189b6f485abea1466928cae7a687d91ea89a0f92f1
5
5
  SHA512:
6
- metadata.gz: bf1dc354f76a69d2ba75068e40a81fa06298361aea896adf104d7be4e76eabb1a09d5e0a600579e48aaa928603723c62eea28f2055e10a1ed2fcf7ef72190df0
7
- data.tar.gz: e5dce5021199db9832bdfec2c8b3d73787bd1a3bf62f465b3ede7522661694d96b3309b7a54b0978ceaf3c799a3c85f12251584937afe4e24de861f99c7e369e
6
+ metadata.gz: ce7abc148ade4c43749fbae9f2adaad0ce568ddeb4867c0d57a5090e25b1548ccc77e04ab46f946351abdc57e71c3ecfd62433898588fc3c3593ca79e4ad8ed1
7
+ data.tar.gz: 6b7a293822cba0ee6c39d7d65d3501ef0a8c931a036c8c71a22be0e6bd286f667897242866d773ac213d0988edfd0673c4b278306befd4ab1d9129aeb87603f2
data/README.md CHANGED
@@ -29,11 +29,11 @@ class TestModel
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
31
  validates :date, date: true
32
- validates :hiragana, hiragana: true
33
- validates :katakana, katakana: true
32
+ validates :hiragana, hiragana: true # hiragana: { allow_space: true }
33
+ validates :katakana, katakana: true # katakana: { allow_space: true }
34
34
  validates :version_number, version_number: true
35
- validates :accept_word, available_word: {accept_words: %w(accept available)}
36
- validates :reject_word, available_word: {reject_words: %w(reject unavailable)}
35
+ validates :accept_word, available_word: { accept_words: %w(accept available) }
36
+ validates :reject_word, available_word: { reject_words: %w(reject unavailable) }
37
37
  validates :large_value, numerical_comparison: { greater_than: :small_value }
38
38
  validates :large_value, numerical_comparison: { greater_than_or_equal_to: :small_value }
39
39
  validates :large_value, numerical_comparison: { equal_to: :small_value }
@@ -2,7 +2,8 @@ module ActiveModel
2
2
  module Validations
3
3
  class HiraganaValidator < EachValidator
4
4
  def validate_each(record, attribute, value)
5
- unless value =~ /\A[\p{hiragana}ー-]*\z/i
5
+ space = options[:allow_space] ? '[:blank:]' : ''
6
+ unless value =~ /\A[\p{hiragana}#{space}ー-]*\z/i
6
7
  record.errors.add(attribute, options[:message] || I18n.t('errors.messages.invalid'))
7
8
  end
8
9
  end
@@ -2,7 +2,8 @@ module ActiveModel
2
2
  module Validations
3
3
  class KatakanaValidator < EachValidator
4
4
  def validate_each(record, attribute, value)
5
- unless value =~ /\A[\p{katakana}ー-]*\z/i
5
+ space = options[:allow_space] ? '[:blank:]' : ''
6
+ unless value =~ /\A[\p{katakana}ー-#{space}]*\z/i
6
7
  record.errors.add(attribute, options[:message] || I18n.t('errors.messages.invalid'))
7
8
  end
8
9
  end
@@ -2,9 +2,9 @@ module ActiveModel
2
2
  module Validations
3
3
  class PhoneNumberValidator < EachValidator
4
4
  REGEXES = {
5
- default: /\A\d{2,4}\-?\d{2,4}\-?\d{3,4}\z/i,
6
- with_hiphenation: /\A\d{2,4}\-\d{2,4}\-\d{3,4}\z/i,
7
- without_hiphenation: /\A\d{6,12}\z/i
5
+ default: /\A0\d{1,4}\-?\d{1,4}\-?\d{1,4}\z/i,
6
+ with_hiphenation: /\A0\d{1,4}\-\d{1,4}\-\d{1,4}\z/i,
7
+ without_hiphenation: /\A0\d{9,10}\z/i
8
8
  }
9
9
 
10
10
  def validate_each(record, attribute, value)
@@ -16,8 +16,8 @@ module ActiveModel
16
16
  when options[:hiphenation] == false
17
17
  REGEXES[:without_hiphenation]
18
18
  end
19
-
20
- unless value =~ regexp
19
+ valid_length = [10, 11].include?((value.gsub('-', '').length))
20
+ unless value =~ regexp && valid_length
21
21
  record.errors.add(attribute, options[:message] || I18n.t('errors.messages.invalid'))
22
22
  end
23
23
  end
@@ -1,3 +1,3 @@
1
1
  module Roshi
2
- VERSION = '0.8.2'
2
+ VERSION = '0.8.3'
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.8.2
4
+ version: 0.8.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - kawahiro311
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2019-02-22 00:00:00.000000000 Z
13
+ date: 2019-03-22 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activemodel
@@ -128,7 +128,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
128
128
  - !ruby/object:Gem::Version
129
129
  version: '0'
130
130
  requirements: []
131
- rubygems_version: 3.0.1
131
+ rubygems_version: 3.0.2
132
132
  signing_key:
133
133
  specification_version: 4
134
134
  summary: ActiveModel/ActiveRecord Validation Collection