{"id":13879401,"url":"https://github.com/monterail/gate","last_synced_at":"2025-12-24T09:46:54.694Z","repository":{"id":34093206,"uuid":"37917821","full_name":"monterail/gate","owner":"monterail","description":"Handling user input with ease","archived":false,"fork":false,"pushed_at":"2019-06-12T13:15:20.000Z","size":90,"stargazers_count":27,"open_issues_count":2,"forks_count":2,"subscribers_count":66,"default_branch":"master","last_synced_at":"2024-10-31T14:41:30.610Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://github.com/monterail/gate","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/monterail.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-06-23T12:31:50.000Z","updated_at":"2022-01-06T10:27:38.000Z","dependencies_parsed_at":"2022-07-18T01:11:20.777Z","dependency_job_id":null,"html_url":"https://github.com/monterail/gate","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/monterail%2Fgate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/monterail%2Fgate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/monterail%2Fgate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/monterail%2Fgate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/monterail","download_url":"https://codeload.github.com/monterail/gate/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226143895,"owners_count":17580245,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-06T08:02:19.800Z","updated_at":"2025-12-24T09:46:54.668Z","avatar_url":"https://github.com/monterail.png","language":"Ruby","funding_links":[],"categories":["Ruby"],"sub_categories":[],"readme":"# Gate\n\n[![Gem Version](https://badge.fury.io/rb/gate.svg)](http://badge.fury.io/rb/gate)\n[![Circle CI](https://circleci.com/gh/monterail/gate.svg?style=shield)](https://circleci.com/gh/monterail/gate)\n[![Code Climate](https://codeclimate.com/github/monterail/gate/badges/gpa.svg)](https://codeclimate.com/github/monterail/gate)\n[![Test Coverage](https://codeclimate.com/github/monterail/gate/badges/coverage.svg)](https://codeclimate.com/github/monterail/gate/coverage)\n\n**Gate** is a small wrapper on [dry-validation](http://dry-rb.org/gems/dry-validation/) that integrates it with [Ruby on Rails](https://rubyonrails.org/) and replaces [Strong Params](http://api.rubyonrails.org/classes/ActionController/Parameters.html).\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'gate'\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install gate\n\n## Usage\n\nDefine [contract](https://dry-rb.org/gems/dry-validation) per action with controller DSL...\n\n```ruby\nclass ExampleController \u003c ActionController::Base\n  include Gate::Rails\n\n  before_action :verify_contract, if: { |c| c.contract_registered? }\n\n  # Define contract just before action method\n  contract(handler: :handle_invalid_params) do\n    params do\n      required(:id).filled\n      required(:message).hash do\n        required(:title).filled\n        optional(:value).maybe(:decimal?)\n      end\n    end\n  end\n\n  def foo\n    # you can access Dry::Validation result with:\n    claimed_params\n  end\n\n  # handler for invalid params\n  def handle_invalid_params(_errors)\n    # errors is Dry::Validation messages hash\n\n    head :bad_request\n  end\nend\n```\n\n... or as a separate class:\n\n```ruby\nclass ExampleFooContract \u003c Dry::Validation::Contract\n  params do\n    required(:id).filled\n    required(:message).hash do\n      required(:title).filled\n      optional(:value).maybe(:decimal?)\n    end\n  end\nend\n\nclass ExampleController \u003c ActionController::Base\n  include Gate::Rails\n\n  before_action :verify_contract, if: { |c| c.contract_registered? }\n\n  contract(ExampleFooContract)\n  def foo\n    # you can access Dry::Validation result with:\n    claimed_params\n  end\n\n  # just use default handler\n  def handle_invalid_params(_errors)\n    # errors is Dry::Validation messages hash\n\n    head :bad_request\n  end\nend\n```\n\n## Configuration\n\n*TODO*\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n## Contributing\n\n1. Fork it ( https://github.com/[my-github-username]/gate/fork )\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create a new Pull Request\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmonterail%2Fgate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmonterail%2Fgate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmonterail%2Fgate/lists"}