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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 941c355a142a261c61928481ee8a1ebeceecce89d37f2491168b15c975369411
|
4
|
+
data.tar.gz: b3214c0160dc30074bb7fe189b6f485abea1466928cae7a687d91ea89a0f92f1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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
|
-
|
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: /\
|
6
|
-
with_hiphenation: /\
|
7
|
-
without_hiphenation: /\
|
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
|
data/lib/roshi/version.rb
CHANGED
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.
|
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-
|
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.
|
131
|
+
rubygems_version: 3.0.2
|
132
132
|
signing_key:
|
133
133
|
specification_version: 4
|
134
134
|
summary: ActiveModel/ActiveRecord Validation Collection
|