Skip to content

Require filter definition for each input #482

@nvanoorschot

Description

@nvanoorschot

We sometimes use AI to manually perform certain custom actions. This exposes us to human errors in the naming of optional arguments. Is it possible to have AI fail if arguments are passed for which no filter has been defined?

Example

class ObjectInteraction < ActiveInteraction::Base
  boolean :commit, default: true

  def execute
    commit_transaction if commit?
  end
end

This command will unintentionally commit the transaction since the argument is misspelled.

ObjectInteraction.run!(comit: false)

Solution?

Introduce a class method and/or global option that changes the default behavior.

class ObjectInteraction < ActiveInteraction::Base
  enforce_filters!
end
ObjectInteraction.run!(comit: false)
# => ActiveInteraction::MissingFilterError: no filter defined for argument `comit`

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions