active_interaction icon indicating copy to clipboard operation
active_interaction copied to clipboard

Run validations when type check failed

Open antulik opened this issue 7 years ago • 3 comments

Not a big issue, but could be annoying

For example let's assume we have a active_interaction object used as a form object.

class SomeForm < ActiveInteraction::Base
  integer :value
  string :comment

  validates_presence_of :comment

  def execute
  end
end

Currently When user enters incorrect number, he gets an error for value but no error for comment. Once the value error is fixed user submits the form and now gets error on comment. Which looks strange as on the previous submit there were no errors for comment.

How it should be In this use case we need to present all errors at once, including type and validation errors.

Currently don't know any work around for it. And would be nice to have such feature by default. Thoughts?

antulik avatar Sep 14 '17 07:09 antulik

See #354, #300, and #223. This is the expected behavior:

When you run this interaction, two things will happen. First ActiveInteraction will type check your inputs. Then ActiveModel will validate them. If both of those are happy, it will be executed.

https://github.com/orgsync/active_interaction/tree/v3.5.2#validations

tfausak avatar Sep 14 '17 12:09 tfausak

This has come up several times which means it might be worth revisiting. I'm already doing a major error overhaul in v4.0.0.

AaronLasseigne avatar Sep 14 '17 17:09 AaronLasseigne

As workaround it is possible to use everything as interface to skip type validation, right?

hurrycaner avatar Feb 06 '18 23:02 hurrycaner