state_validator 1.0 → 1.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/README.md +3 -1
- data/lib/state_validator.rb +1 -1
- data/lib/state_validator/version.rb +1 -1
- data/state_validator.gemspec +1 -1
- metadata +11 -6
data/README.md
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
# StateValidator
|
2
2
|
|
3
|
-
|
3
|
+
A custom validator for stateful attributes of ActiveRecord objects.
|
4
|
+
It's work like an inclusion validation and it's need for you if you are
|
5
|
+
use RailsAdmin, also for State Machine implementation with the transition_validator gem.
|
4
6
|
|
5
7
|
## Installation
|
6
8
|
|
data/lib/state_validator.rb
CHANGED
@@ -2,6 +2,6 @@ require 'state_validator/version'
|
|
2
2
|
|
3
3
|
class StateValidator < ActiveModel::EachValidator
|
4
4
|
def validate_each(record, attribute, value)
|
5
|
-
record.errors[attribute] << I18n.t('errors.messages.inclusion') if
|
5
|
+
record.errors[attribute] << I18n.t('errors.messages.inclusion') if record.send("#{attribute}_enum".to_sym).include?(value.to_s)
|
6
6
|
end
|
7
7
|
end
|
data/state_validator.gemspec
CHANGED
@@ -4,7 +4,7 @@ require File.expand_path('../lib/state_validator/version', __FILE__)
|
|
4
4
|
Gem::Specification.new do |gem|
|
5
5
|
gem.authors = ['Nick Nizovtsev']
|
6
6
|
gem.email = ['nizovtsevnv@gmail.com']
|
7
|
-
gem.description = %q{
|
7
|
+
gem.description = %q{A custom validator for stateful attributes of ActiveRecord objects.}
|
8
8
|
gem.summary = %q{Validate values of stateful attributes.}
|
9
9
|
gem.homepage = 'http://github.com/nizovtsevnv/state_validator'
|
10
10
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: state_validator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.0.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-07-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activemodel
|
16
|
-
requirement:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,8 +21,13 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
25
|
-
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
description: A custom validator for stateful attributes of ActiveRecord objects.
|
26
31
|
email:
|
27
32
|
- nizovtsevnv@gmail.com
|
28
33
|
executables: []
|
@@ -57,7 +62,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
57
62
|
version: '0'
|
58
63
|
requirements: []
|
59
64
|
rubyforge_project:
|
60
|
-
rubygems_version: 1.8.
|
65
|
+
rubygems_version: 1.8.24
|
61
66
|
signing_key:
|
62
67
|
specification_version: 3
|
63
68
|
summary: Validate values of stateful attributes.
|