How about wrapping this up into a method?

```ruby
# return true if empty_ok exists and is an accepted value
# otherwise returns fasle
def empty_ok?(empty_ok)
  if empty_ok
    empty_ok = empty_ok.downcase
    unless %w[yes y 1 true].include?(empty_ok)
      log(action: "check", at: "invalid_empty_ok", val: empty_ok)
      halt 400, JSON.dump({"error" => "empty_ok must be one of yes/y/1/true"}) + "\n"
    end
    return true
  end
  return false
end

# And then...
empty_ok = empty_ok?(params["empty_ok"])
```