validate_specific_value 0.1.0 → 0.1.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.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +38 -18
- data/lib/validate_specific_value/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 98510f8311522413c804ad1e231e8430a074315aabf3cd488f40a09da29dba20
|
4
|
+
data.tar.gz: a1d662dea74166631f59d6915c4ad54ac939fd969832bd7b5d2c3f9476441fd6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 685f0bfbd8c1be750646abd8694cba7aa48084da9815932595a9dca9eb624547e3024edc0aa4ee448c4560426597cbcc77c66a25ab8f86b8fd0b0416a61339c8
|
7
|
+
data.tar.gz: '088f2138531f3f7fb7fdb505bb922d2d17694f165dcf93b4b1b6f7c73b6aa3f011cab36d0e32891963264e71c0c955f980843cb0ef0f70b81e34fa80515ed947'
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,39 +1,59 @@
|
|
1
|
-
#
|
1
|
+
# validate_specific_value
|
2
2
|
|
3
|
-
|
3
|
+
This is a way to validate single attribute in Rails. :tada:
|
4
4
|
|
5
|
-
|
5
|
+
- accessor methods
|
6
6
|
|
7
|
-
##
|
7
|
+
## Getting Started
|
8
8
|
|
9
|
-
Add this line to your application
|
9
|
+
Add this line to your application’s Gemfile:
|
10
10
|
|
11
11
|
```ruby
|
12
12
|
gem 'validate_specific_value'
|
13
13
|
```
|
14
14
|
|
15
|
-
|
15
|
+
Add a validation rule to your model.
|
16
16
|
|
17
|
-
|
17
|
+
```ruby
|
18
|
+
validates :name, uniqueness: true
|
19
|
+
```
|
18
20
|
|
19
|
-
|
21
|
+
And use:
|
20
22
|
|
21
|
-
|
23
|
+
```ruby
|
24
|
+
class User < ApplicationRecord
|
25
|
+
validates_specific :name
|
26
|
+
end
|
27
|
+
```
|
22
28
|
|
23
|
-
|
29
|
+
The first value will be the initial value. This gives you:
|
24
30
|
|
25
|
-
|
31
|
+
#### Accessor Methods
|
26
32
|
|
27
|
-
|
33
|
+
Instance context:
|
28
34
|
|
29
|
-
|
35
|
+
```ruby
|
36
|
+
user = User.new(name: 'duplicate_name')
|
37
|
+
user.valid_name?
|
38
|
+
# => false
|
30
39
|
|
31
|
-
|
40
|
+
user.errors[:name]
|
41
|
+
# =>
|
32
42
|
|
33
|
-
|
43
|
+
```
|
44
|
+
|
45
|
+
Class context:
|
46
|
+
|
47
|
+
```ruby
|
48
|
+
User.valid_name?('duplicate_name')
|
49
|
+
# => false
|
50
|
+
```
|
34
51
|
|
35
|
-
|
52
|
+
## Contributing
|
36
53
|
|
37
|
-
|
54
|
+
Everyone is encouraged to help improve this project. Here are a few ways you can help:
|
38
55
|
|
39
|
-
|
56
|
+
- [Report bugs](https://github.com/ts-3156/validate_specific_value/issues)
|
57
|
+
- Fix bugs and [submit pull requests](https://github.com/ts-3156/validate_specific_value/pulls)
|
58
|
+
- Write, clarify, or fix documentation
|
59
|
+
- Suggest or add new features
|