data_validator 0.0.4 → 0.0.5

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 CHANGED
@@ -1,5 +1,55 @@
1
1
  # DataValidator [![Build Status](https://travis-ci.org/SpringMT/data_validator.png)](https://travis-ci.org/SpringMT/data_validator)
2
2
 
3
+ DataValidator is validation everywhere.
4
+ For Example, Controller or else.
5
+
6
+ ## Sample
7
+
8
+ ~~~
9
+ params = {foo: 'foo', bar: 'bar'}
3
10
  params,
4
11
  {foo: {length: {is: 4}}},
5
12
  {bar: {presence: true, format: {with: /\A[a-zA-Z]+\z/}}}
6
13
  @errors = validator.errors
7
14
  foo: ["is the wrong length (should be 4 characters)"],
8
15
  bar: ["can't be blank", "is invalid"]
16
+ ~~~
17
+
18
+ ## Validation logic
19
+ DataValidator has almost AR validation logics by default.
20
+
21
+ * acceptance
22
+ * confirmation
23
+ * format
24
+ * inclusion
25
+ * length
26
+ * numericality
27
+ * presence
28
+
29
+ ## Error message
30
+ DataValidator supports i18n.
31
+ If you use rails, you not worry about locale file.
32
+
33
+ ## Original Validation
34
+ Ex)
35
+
36
+ ~~~
37
+ # encoding: UTF-8
38
+
39
+ module DataValidator
40
+ class TestValidator < BaseValidator
41
+ def validate
42
+ if options && values !~ /[^@]+$/
43
+ error_add :invalid_test, test: value
44
+ end
45
+ end
46
+ end
47
+ end
48
+ ~~~
49
+
50
+ BaseValidator set accessors below.
51
+
52
+ * name : validating parmater name
53
+ * value : validating paramter value
54
+ * options : validation rules
55
+
56
+ Please see test case.
57
+
58
+
9
59
  ## Installation
10
60
 
11
61
  Add this line to your application's Gemfile:
@@ -8,7 +58,7 @@ Add this line to your application's Gemfile:
8
58
 
9
59
  And then execute:
10
60
 
11
- $ bundle
61
+ $ bundle install
12
62
 
13
63
  Or install it yourself as:
14
64
 
@@ -1,3 +1,3 @@
1
1
  module DataValidator
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
@@ -19,9 +19,6 @@ module DataValidator
19
19
  end
20
20
 
21
21
  private
22
- # In Ruby 1.9 <tt>Range#include?</tt> on non-numeric ranges checks all possible values in the
23
- # range for equality, so it may be slow for large ranges. The new <tt>Range#cover?</tt>
24
- # uses the previous logic of comparing a value with the range endpoints.
25
22
  def inclusion_method(enumerable)
26
23
  enumerable.is_a?(Range) ? :cover? : :include?
27
24
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: data_validator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
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-11-19 00:00:00.000000000 Z
12
+ date: 2012-11-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
16
- requirement: &70337154263120 !ruby/object:Gem::Requirement
16
+ requirement: &70228574791740 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 3.2.0
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70337154263120
24
+ version_requirements: *70228574791740
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: i18n
27
- requirement: &70337154261840 !ruby/object:Gem::Requirement
27
+ requirement: &70228593410360 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,7 +32,7 @@ dependencies:
32
32
  version: '0.6'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70337154261840
35
+ version_requirements: *70228593410360
36
36
  description: ! ' DataValidator has almost active_recorde validation methods.
37
37
 
38
38
  '