paranoid_starlight 2.0 → 2.0.1
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.
- data/.gitignore +1 -0
- data/README.md +2 -2
- data/lib/paranoid_starlight.rb +1 -1
- data/lib/paranoid_starlight/attributes/validations.rb +6 -1
- data/lib/paranoid_starlight/converters.rb +2 -2
- data/lib/paranoid_starlight/version.rb +1 -1
- data/specs/paranoid_starlight/attributes_validations_spec.rb +4 -1
- metadata +2 -2
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -60,7 +60,7 @@ If you required active_record hook, you can use:
|
|
60
60
|
validates_email_format_of :email
|
61
61
|
validates_name_format_of :name
|
62
62
|
# few different valid formats are allowed
|
63
|
-
|
63
|
+
validates_telephone_number_convertibility_of :telephone, :mobile
|
64
64
|
# or validates :email, :email => true
|
65
65
|
|
66
66
|
before_save :convert_fields
|
@@ -85,7 +85,7 @@ Currently there are these possibilities:
|
|
85
85
|
|
86
86
|
- validates_email_format_of
|
87
87
|
- validates_name_format_of
|
88
|
-
-
|
88
|
+
- validates_telephone_number_convertibility_of
|
89
89
|
|
90
90
|
*Converters for attributes* (getter and setter methods in object are enough)
|
91
91
|
|
data/lib/paranoid_starlight.rb
CHANGED
@@ -14,7 +14,12 @@ module ParanoidStarlight
|
|
14
14
|
def validates_name_format_of(*attr_names)
|
15
15
|
validates_with ::ParanoidStarlight::Validators::NameValidator, _merge_attributes(attr_names)
|
16
16
|
end
|
17
|
-
|
17
|
+
|
18
|
+
def validates_telephone_number_convertibility_of(*attr_names)
|
19
|
+
validates_with ::ParanoidStarlight::Validators::TelephoneValidator, _merge_attributes(attr_names)
|
20
|
+
end
|
21
|
+
|
22
|
+
# will be deprecated or reworked
|
18
23
|
def validates_telephone_number_of(*attr_names)
|
19
24
|
validates_with ::ParanoidStarlight::Validators::TelephoneValidator, _merge_attributes(attr_names)
|
20
25
|
end
|
@@ -1,8 +1,8 @@
|
|
1
1
|
module ParanoidStarlight
|
2
2
|
module Converters
|
3
3
|
def convert_telephone(num, prefixcc = 421)
|
4
|
-
telephone = num.to_s
|
5
|
-
prefixcc = prefixcc.to_s
|
4
|
+
telephone = num.to_s.dup
|
5
|
+
prefixcc = prefixcc.to_s.dup
|
6
6
|
|
7
7
|
# convert logic
|
8
8
|
# possible formats, with or without spaces
|
@@ -22,7 +22,10 @@ end
|
|
22
22
|
|
23
23
|
class TestTelephone < WithValidations
|
24
24
|
attr_accessor :telephone
|
25
|
-
|
25
|
+
|
26
|
+
# will be deprecated or reqorked
|
27
|
+
# validates_telephone_number_of :telephone
|
28
|
+
validates_telephone_number_convertibility_of :telephone
|
26
29
|
end
|
27
30
|
|
28
31
|
describe ParanoidStarlight::Attributes::Validations do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: paranoid_starlight
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-01-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activemodel
|