Skip to content

Conversation

rewinfrey
Copy link
Owner

Taking inspiration from #10 I wanted to see how it felt maintaining two sets of validation methods and invoke them at the ActionLogic::ActionCore level.

I also took inspiration from ActiveModel::Errors so if the non-bang validation method is used and errors are found, ActionLogic provides a context.errors.messages interface:

{
  :integer_attribute=>"Value expected to be of type Fixnum but is NilClass", 
  :float_attribute=>"Value expected to be of type Float but is NilClass"
}

I've updated the three types of validations (Attribute, Presence and Type) to support this difference, and am still working through updating the tests and fixtures.

My goal isn't to replace #10 but to compare approaches and see if some mix and match would be ideal, or if we like one direction or the other.

/cc @davesims

@codecov-io
Copy link

codecov-io commented Apr 20, 2017

Codecov Report

Merging #11 into master will decrease coverage by 4.5%.
The diff coverage is 78.1%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #11      +/-   ##
==========================================
- Coverage    99.1%   94.59%   -4.51%     
==========================================
  Files          22       23       +1     
  Lines         668      740      +72     
==========================================
+ Hits          662      700      +38     
- Misses          6       40      +34
Impacted Files Coverage Δ
lib/action_logic/action_validation/errors.rb 100% <100%> (ø)
lib/action_logic/action_context.rb 100% <100%> (ø) ⬆️
lib/action_logic/action_core.rb 100% <100%> (ø) ⬆️
.../action_logic/action_validation/type_validation.rb 70% <14.28%> (-30%) ⬇️
...on_logic/action_validation/attribute_validation.rb 68.75% <16.66%> (-31.25%) ⬇️
...ion_logic/action_validation/presence_validation.rb 62.5% <42.85%> (-37.5%) ⬇️
spec/action_logic/active_use_case_spec.rb 92.9% <83.87%> (-7.1%) ⬇️
lib/action_logic/action_validation.rb 98.24% <96.87%> (-1.76%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d4599fc...1b3e54c. Read the comment docs.

@davesims
Copy link

👍 This was actually the approach I took on my first stab at it. This way feels less hacky to me and a lot cleaner. I am moving forward on unit tests on #10, I think they'll be pretty interchangeable with either approach.

@rewinfrey
Copy link
Owner Author

Closing out as stale. Happy to revisit this if this functionality would be useful.

cc/ @davesims

@rewinfrey rewinfrey closed this Dec 18, 2018
@rewinfrey rewinfrey deleted the conditional-exception-validations branch December 18, 2018 05:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants