formify 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 72de11fb4c4933d16cd59cce57c64c037cc7abb16bd82d3d6bdf7b865e403c46
4
- data.tar.gz: 0f3e5a864f982eb1a9a56b7694e073d69da47b793233f42a3cea203027ea3601
3
+ metadata.gz: 070f0acf8fa985c539c0a758ebc8109c8346106b8b96d41ca59b54dbef027318
4
+ data.tar.gz: d4983fd2ac3c69e710745848e46a1d934056f96690e271931d15bd6395ddb31e
5
5
  SHA512:
6
- metadata.gz: 28f012f82c0bec95ceceb3a9ac9611887e197aa42ef0786a68bc3360b810bd47f9de5d8c021f4b581d9db4bacae9599d6c3eafde4dab9a0179395d3fa63f4259
7
- data.tar.gz: 675d7a158bcb082a598fa0020d328500bfab58c550fb6df8ad25ebe7e0ff5b6bba507e64afb6c3aed1b224b68635765ffeb052bdd9319373372c3549ea77441c
6
+ metadata.gz: 25d86b66ddaa3a46fa0a761bd27cf1097d3071fbf38e7d9988c76e31a78a0dc78f4aec8de6710461d0acaf055acedafa4ec65083d207acde445c9f307dac656f
7
+ data.tar.gz: 2702552193584f18d3f40431724e7569c33e2ad95a59e250658a0a7eac94e9cfe2e0c818cefdc8b9997e2e7c63ea3c30e626f6b8977fb97de4df8c5e4f6769c5
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- formify (0.4.0)
4
+ formify (0.5.0)
5
5
  resonad
6
6
 
7
7
  GEM
@@ -0,0 +1,12 @@
1
+ module Formify
2
+ module Errors
3
+ class FormError < StandardError
4
+ attr_reader :form
5
+
6
+ def initialize(form:, message:)
7
+ @form = form
8
+ super(message)
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,16 @@
1
+ module Formify
2
+ module Errors
3
+ class ValidationError < Formify::Errors::FormError
4
+ attr_reader :attribute
5
+
6
+ def initialize(form:)
7
+ @attribute = form.errors.first.first
8
+
9
+ super(
10
+ form: form,
11
+ message: form.errors.full_messages_for(@attribute).first
12
+ )
13
+ end
14
+ end
15
+ end
16
+ end
data/lib/formify/form.rb CHANGED
@@ -44,7 +44,7 @@ module Formify
44
44
  def validate_or_fail(*instances)
45
45
  unless valid?
46
46
  return Resonad.Failure(
47
- Forms::Errors::ValidationError.new(form: self)
47
+ Formify::Errors::ValidationError.new(form: self)
48
48
  )
49
49
  end
50
50
 
@@ -53,7 +53,7 @@ module Formify
53
53
  next if instance.valid?
54
54
 
55
55
  return Resonad.Failure(
56
- Forms::Errors::ValidationError.new(form: self, message: instance.full_messages.first)
56
+ Formify::Errors::ValidationError.new(form: self, message: instance.full_messages.first)
57
57
  )
58
58
  end
59
59
  end
@@ -1,3 +1,3 @@
1
1
  module Formify
2
- VERSION = '0.4.0'.freeze
2
+ VERSION = '0.5.0'.freeze
3
3
  end
data/lib/formify.rb CHANGED
@@ -1,6 +1,8 @@
1
1
  require 'formify/version'
2
2
  require 'resonad'
3
3
 
4
+ require 'formify/errors/form_error'
5
+ require 'formify/errors/validation_error'
4
6
  require 'formify/form'
5
7
  require 'formify/spec_helpers'
6
8
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: formify
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Jackson
@@ -88,6 +88,8 @@ files:
88
88
  - bin/setup
89
89
  - formify.gemspec
90
90
  - lib/formify.rb
91
+ - lib/formify/errors/form_error.rb
92
+ - lib/formify/errors/validation_error.rb
91
93
  - lib/formify/form.rb
92
94
  - lib/formify/spec_helpers.rb
93
95
  - lib/formify/version.rb