boolean_validator 0.1.0
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 +7 -0
- data/README.md +43 -0
- data/Rakefile +6 -0
- data/lib/boolean_validator.rb +9 -0
- metadata +60 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: cea3c2b44f571c7f1387a1d154e27e70e7dea6358e7fc9c9728221743dc4ad22
|
4
|
+
data.tar.gz: 6c882fcd039e8bc676353e84134a9fe8a833f78c15fb950cafa83a85909b8d39
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5ac50b6791a526d6ddc29838e0aa7990a7ed01d0dd0f2a879799799eeb2b619dcb2faa19f928de39cd9ea833d2f3bc7f8605a2a610fd5b10c1ad200311fc7c65
|
7
|
+
data.tar.gz: 16c521e13d67bbf99b8801a159206391931b65c872f0dc1d3c31cab2e0e06ed0963916b6bfc4d9e4f2e472f82f4126b2d17c9842b0fb2651d8f9127791bb7ce8
|
data/README.md
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
# BooleanValidator
|
2
|
+
|
3
|
+
This gem enables your Rails-based app to validate boolean values much easier.
|
4
|
+
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
Add this line to your application's Gemfile:
|
9
|
+
|
10
|
+
```ruby
|
11
|
+
gem 'boolean_validator'
|
12
|
+
```
|
13
|
+
|
14
|
+
And then execute:
|
15
|
+
|
16
|
+
$ bundle
|
17
|
+
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
In your model:
|
22
|
+
```ruby
|
23
|
+
class Post < ActiveRecord::Base
|
24
|
+
validates :is_public, boolean: true
|
25
|
+
end
|
26
|
+
```
|
27
|
+
|
28
|
+
or you can pass an option like:
|
29
|
+
|
30
|
+
```ruby
|
31
|
+
class Post < ActiveRecord::Base
|
32
|
+
validate :is_public, boolean: { message: 'Customize your error message' }
|
33
|
+
end
|
34
|
+
```
|
35
|
+
|
36
|
+
|
37
|
+
## Contributing
|
38
|
+
|
39
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/spice-inc/boolean_validator.
|
40
|
+
|
41
|
+
## License
|
42
|
+
|
43
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
require 'active_model/validator'
|
2
|
+
|
3
|
+
class BooleanValidator < ActiveModel::EachValidator
|
4
|
+
def validate_each(record, attribute, value)
|
5
|
+
return if [true, false].include?(value)
|
6
|
+
|
7
|
+
record.errors.add(attribute, :invalid, options.slice(:message).merge(value: value))
|
8
|
+
end
|
9
|
+
end
|
metadata
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: boolean_validator
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- ayumitamai97
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-04-28 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: activemodel
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 5.0.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 5.0.0
|
27
|
+
description: Boolean validator for Rails and ActiveModel.
|
28
|
+
email:
|
29
|
+
- ayumitamai97@gmail.com
|
30
|
+
executables: []
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- README.md
|
35
|
+
- Rakefile
|
36
|
+
- lib/boolean_validator.rb
|
37
|
+
homepage: https://github.com/ayumitamai97
|
38
|
+
licenses:
|
39
|
+
- MIT
|
40
|
+
metadata: {}
|
41
|
+
post_install_message:
|
42
|
+
rdoc_options: []
|
43
|
+
require_paths:
|
44
|
+
- lib
|
45
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '0'
|
50
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
requirements: []
|
56
|
+
rubygems_version: 3.0.3
|
57
|
+
signing_key:
|
58
|
+
specification_version: 4
|
59
|
+
summary: Boolean validator for Rails and ActiveModel.
|
60
|
+
test_files: []
|