converters_before_validation 0.1.1 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -5
- data/lib/converters_before_validation.rb +1 -1
- data/lib/converters_before_validation/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a3f66896b57979bbccc1ce2016d76eaada25f044da4ef28bee14b7a87a52aca0
|
4
|
+
data.tar.gz: 2917bcd1c5f63ddf8779c8ea1f7141f55e26352e9e026025f05453877f9cc3ef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3fb0f73276c86589eb6e140ce7a6895162924de224be086de61ac6aae35cfb50b5454a9aaea02b915df1329c664a2432c981e6b9f0b1f007bcbdfb32ca27fdc4
|
7
|
+
data.tar.gz: '0419d9b00824353857eb3ba46abc280872c53fcd8ee96e3540fdb7e6115edc9bba35f3da5ccc04d7eff44eb1dd7ada229e9511c8dd173bf05b963f26f7cb4997'
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# ConvertersBeforeValidation
|
2
2
|
|
3
|
-
string_converter_before_validation adds before_validation callback, which
|
3
|
+
string_converter_before_validation adds before_validation callback, which applies necessary function to attributes.
|
4
4
|
|
5
5
|
There are some derivatives:
|
6
6
|
|
@@ -10,7 +10,7 @@ There are some derivatives:
|
|
10
10
|
|
11
11
|
## Usage
|
12
12
|
|
13
|
-
Let we have model Article with
|
13
|
+
Let's suppose we have model Article with following fields: author_name, contact_email, title, camel_tag.
|
14
14
|
|
15
15
|
```ruby
|
16
16
|
# app/models/article.rb
|
@@ -21,7 +21,7 @@ Let we have model Article with some fields: author_name, contact_email, title, c
|
|
21
21
|
end
|
22
22
|
```
|
23
23
|
|
24
|
-
|
24
|
+
We're setting values for these fields sourced from some inaccurate input:
|
25
25
|
|
26
26
|
```
|
27
27
|
>> article = Article.new(author_name: ' Boss ', contact_email: ' Boss@ExAmple.Org', title: ' hello ', camel_tag: 'hello_world')
|
@@ -43,13 +43,14 @@ Let's take fields' values from some not accurate input:
|
|
43
43
|
|
44
44
|
```
|
45
45
|
|
46
|
-
|
46
|
+
We might want to sanitize our values before saving it to our database:
|
47
47
|
contact_email = contact_email.squish.downcase
|
48
48
|
author_name = author_name.squish
|
49
49
|
title = title.squish.upcase
|
50
50
|
camel_tag = camel_tag.camelcase
|
51
51
|
|
52
|
-
This gem's functions are
|
52
|
+
This gem's functions are presented for doing this:
|
53
|
+
before_validation callbacks added to its model and do the job.
|
53
54
|
|
54
55
|
```ruby
|
55
56
|
# app/models/article.rb
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: converters_before_validation
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kanaikin Slava
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-09-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -56,14 +56,14 @@ dependencies:
|
|
56
56
|
requirements:
|
57
57
|
- - "~>"
|
58
58
|
- !ruby/object:Gem::Version
|
59
|
-
version: 6.0.0
|
59
|
+
version: 6.0.0
|
60
60
|
type: :development
|
61
61
|
prerelease: false
|
62
62
|
version_requirements: !ruby/object:Gem::Requirement
|
63
63
|
requirements:
|
64
64
|
- - "~>"
|
65
65
|
- !ruby/object:Gem::Version
|
66
|
-
version: 6.0.0
|
66
|
+
version: 6.0.0
|
67
67
|
- !ruby/object:Gem::Dependency
|
68
68
|
name: sqlite3
|
69
69
|
requirement: !ruby/object:Gem::Requirement
|
@@ -78,8 +78,8 @@ dependencies:
|
|
78
78
|
- - ">="
|
79
79
|
- !ruby/object:Gem::Version
|
80
80
|
version: '0'
|
81
|
-
description: 'Adds before_validation callback, which
|
82
|
-
There are some derivatives: squish_before_validation_for, downcase_before_validation_for,
|
81
|
+
description: 'Adds before_validation callback, which applies necessary function to
|
82
|
+
attributes. There are some derivatives: squish_before_validation_for, downcase_before_validation_for,
|
83
83
|
upcase_before_validation_for.'
|
84
84
|
email:
|
85
85
|
- sportix@gotar.ru
|