rasti-form 1.0.1 → 1.0.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e569c6d3294a2d755878465ed47c2be552349d22
4
- data.tar.gz: eac5ece907a3eb5d36eda217183e2bb9eaae89e4
3
+ metadata.gz: 4d80510c787edb2b4e300a9c42aacf98dc93a188
4
+ data.tar.gz: 42cbf2765f69f2e681b068ec26d68dca5acb1a57
5
5
  SHA512:
6
- metadata.gz: 6363b2f3e2b491231416e2dfb2288a3648c37d2854aa421c839f8863d425ee68462af4b92278c9a99e211582cc4700591794fb8acb2f5abd8ac789df6ec32b70
7
- data.tar.gz: 95e29872aba69ce39e2379d7b86fc765ca5eea74043a165ec31877ddbb39271618ad0b0d639c20c3dea10585a0db5c2b359d5fa69e22de09e79afdac508510e2
6
+ metadata.gz: 37a450b673cb95de15c1b13acd555c687211486c442121f093dc530b5a75444eb15708d54fc4b838c4178fc0c3bceeb52e169f459736044e3ead14cc8a16d05e
7
+ data.tar.gz: e24ae1cb69be7eae15483f7b630668af82b08fe34b609c89209fee63b8f7bc92c5f1661bc749a1d749d884d48036944e0ba86b777bb71234c15d7b4ddc76af6c
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- ruby-2.3.0
1
+ ruby-2.4.0
data/.travis.yml CHANGED
@@ -1,4 +1,5 @@
1
1
  language: ruby
2
+
2
3
  rvm:
3
4
  - 1.9.3
4
5
  - 2.0
@@ -6,6 +7,16 @@ rvm:
6
7
  - 2.2
7
8
  - 2.3.0
8
9
  - 2.4.0
9
- - jruby
10
+ - jruby-1.7.25
11
+ - jruby-9.1.7.0
12
+ - ruby-head
13
+ - jruby-head
14
+
15
+ matrix:
16
+ fast_finish: true
17
+ allow_failures:
18
+ - rvm: ruby-head
19
+ - rvm: jruby-head
20
+
10
21
  before_install:
11
22
  - gem install bundler
data/README.md CHANGED
@@ -91,11 +91,11 @@ form.to # => 2016-10-28 00:00:00 -0300
91
91
  - Boolean
92
92
  - Enum
93
93
  - Float
94
+ - Form
94
95
  - Hash
95
96
  - Integer
96
97
  - Regexp
97
98
  - String
98
- - Struct
99
99
  - Symbol
100
100
  - Time
101
101
  - UUID
@@ -25,14 +25,15 @@ module Rasti
25
25
 
26
26
  class ValidationError < StandardError
27
27
 
28
- attr_reader :errors
28
+ attr_reader :scope, :errors
29
29
 
30
- def initialize(errors)
30
+ def initialize(scope, errors)
31
+ @scope = scope
31
32
  @errors = errors
32
33
  end
33
34
 
34
35
  def message
35
- "Validation error: #{JSON.dump(errors)}"
36
+ "Validation error: #{scope} #{JSON.dump(errors)}"
36
37
  end
37
38
 
38
39
  end
@@ -10,7 +10,7 @@ module Rasti
10
10
 
11
11
  def validate!
12
12
  validate
13
- raise ValidationError.new(errors) unless errors.empty?
13
+ raise ValidationError.new(self, errors) unless errors.empty?
14
14
  end
15
15
 
16
16
  def validate
@@ -1,5 +1,5 @@
1
1
  module Rasti
2
2
  class Form
3
- VERSION = '1.0.1'
3
+ VERSION = '1.0.2'
4
4
  end
5
5
  end
data/spec/form_spec.rb CHANGED
@@ -40,7 +40,7 @@ describe Rasti::Form do
40
40
 
41
41
  it 'Invalid attributes' do
42
42
  error = proc { point_class.new z: 3 }.must_raise Rasti::Form::ValidationError
43
- error.message.must_equal 'Validation error: {"z":["unexpected attribute"]}'
43
+ error.message.must_equal 'Validation error: #<Rasti::Form[]> {"z":["unexpected attribute"]}'
44
44
  end
45
45
 
46
46
  describe 'Casting' do
@@ -86,7 +86,7 @@ describe Rasti::Form do
86
86
  end
87
87
 
88
88
  error = proc { form.new boolean: 'x', number: 'y' }.must_raise Rasti::Form::ValidationError
89
- error.message.must_equal 'Validation error: {"boolean":["Invalid cast: \'x\' -> Rasti::Form::Types::Boolean"],"number":["Invalid cast: \'y\' -> Rasti::Form::Types::Integer"]}'
89
+ error.message.must_equal 'Validation error: #<Rasti::Form[]> {"boolean":["Invalid cast: \'x\' -> Rasti::Form::Types::Boolean"],"number":["Invalid cast: \'y\' -> Rasti::Form::Types::Integer"]}'
90
90
  end
91
91
 
92
92
  it 'Invalid nested attributes' do
@@ -95,7 +95,7 @@ describe Rasti::Form do
95
95
  end
96
96
 
97
97
  error = proc { form.new range: {min: 'x', max: 'y'} }.must_raise Rasti::Form::ValidationError
98
- error.message.must_equal "Validation error: {\"range.min\":[\"Invalid cast: 'x' -> Rasti::Form::Types::Integer\"],\"range.max\":[\"Invalid cast: 'y' -> Rasti::Form::Types::Integer\"]}"
98
+ error.message.must_equal "Validation error: #<Rasti::Form[]> {\"range.min\":[\"Invalid cast: 'x' -> Rasti::Form::Types::Integer\"],\"range.max\":[\"Invalid cast: 'y' -> Rasti::Form::Types::Integer\"]}"
99
99
  end
100
100
 
101
101
  it 'Invalid form attributes' do
@@ -109,7 +109,7 @@ describe Rasti::Form do
109
109
  end
110
110
 
111
111
  error = proc { form.new range: {min: 'x', max: 'y'} }.must_raise Rasti::Form::ValidationError
112
- error.message.must_equal "Validation error: {\"range.min\":[\"Invalid cast: 'x' -> Rasti::Form::Types::Integer\"],\"range.max\":[\"Invalid cast: 'y' -> Rasti::Form::Types::Integer\"]}"
112
+ error.message.must_equal "Validation error: #<Rasti::Form[]> {\"range.min\":[\"Invalid cast: 'x' -> Rasti::Form::Types::Integer\"],\"range.max\":[\"Invalid cast: 'y' -> Rasti::Form::Types::Integer\"]}"
113
113
  end
114
114
 
115
115
  end
@@ -151,7 +151,7 @@ describe Rasti::Form do
151
151
  end
152
152
 
153
153
  error = proc { form.new }.must_raise Rasti::Form::ValidationError
154
- error.message.must_equal 'Validation error: {"text":["not present"]}'
154
+ error.message.must_equal 'Validation error: #<Rasti::Form[]> {"text":["not present"]}'
155
155
  end
156
156
 
157
157
  it 'Not empty string' do
@@ -164,7 +164,7 @@ describe Rasti::Form do
164
164
  end
165
165
 
166
166
  error = proc { form.new text: ' ' }.must_raise Rasti::Form::ValidationError
167
- error.message.must_equal 'Validation error: {"text":["is empty"]}'
167
+ error.message.must_equal 'Validation error: #<Rasti::Form[text: " "]> {"text":["is empty"]}'
168
168
  end
169
169
 
170
170
  it 'Not empty array' do
@@ -177,7 +177,7 @@ describe Rasti::Form do
177
177
  end
178
178
 
179
179
  error = proc { form.new array: [] }.must_raise Rasti::Form::ValidationError
180
- error.message.must_equal 'Validation error: {"array":["is empty"]}'
180
+ error.message.must_equal 'Validation error: #<Rasti::Form[array: []]> {"array":["is empty"]}'
181
181
  end
182
182
 
183
183
  it 'Included in values list' do
@@ -190,7 +190,7 @@ describe Rasti::Form do
190
190
  end
191
191
 
192
192
  error = proc { form.new text: 'xyz' }.must_raise Rasti::Form::ValidationError
193
- error.message.must_equal 'Validation error: {"text":["not included in \'value_1\', \'value_2\'"]}'
193
+ error.message.must_equal 'Validation error: #<Rasti::Form[text: "xyz"]> {"text":["not included in \'value_1\', \'value_2\'"]}'
194
194
  end
195
195
 
196
196
  it 'Nested form' do
@@ -204,7 +204,7 @@ describe Rasti::Form do
204
204
  end
205
205
 
206
206
  error = proc { form.new }.must_raise Rasti::Form::ValidationError
207
- error.message.must_equal 'Validation error: {"range.min":["not present"],"range.max":["not present"]}'
207
+ error.message.must_equal 'Validation error: #<Rasti::Form[]> {"range.min":["not present"],"range.max":["not present"]}'
208
208
  end
209
209
 
210
210
  it 'Nested validation' do
@@ -222,7 +222,7 @@ describe Rasti::Form do
222
222
  end
223
223
 
224
224
  error = proc { form.new range: {min: 2, max: 1} }.must_raise Rasti::Form::ValidationError
225
- error.message.must_equal 'Validation error: {"range.min":["Min must be less than Max"]}'
225
+ error.message.must_equal 'Validation error: #<Rasti::Form[]> {"range.min":["Min must be less than Max"]}'
226
226
  end
227
227
 
228
228
  end
@@ -35,7 +35,7 @@ describe Rasti::Form::Types::Form do
35
35
 
36
36
  it '{x: "text"} -> ValidationError' do
37
37
  error = proc { Rasti::Form::Types::Form[form].cast x: 'test' }.must_raise Rasti::Form::ValidationError
38
- error.message.must_equal "Validation error: {\"x\":[\"Invalid cast: 'test' -> Rasti::Form::Types::Integer\"]}"
38
+ error.message.must_equal "Validation error: #<Rasti::Form[]> {\"x\":[\"Invalid cast: 'test' -> Rasti::Form::Types::Integer\"]}"
39
39
  end
40
40
 
41
41
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rasti-form
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gabriel Naiman
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-09-26 00:00:00.000000000 Z
11
+ date: 2017-09-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: multi_require
@@ -207,7 +207,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
207
207
  version: '0'
208
208
  requirements: []
209
209
  rubyforge_project:
210
- rubygems_version: 2.5.1
210
+ rubygems_version: 2.6.8
211
211
  signing_key:
212
212
  specification_version: 4
213
213
  summary: Forms validations and type casting