{"id":16039592,"url":"https://github.com/okirmis/rails-param-validation","last_synced_at":"2025-03-18T04:30:45.449Z","repository":{"id":56890652,"uuid":"245818495","full_name":"okirmis/rails-param-validation","owner":"okirmis","description":"Declarative parameter definition and validation for Rails","archived":false,"fork":false,"pushed_at":"2025-03-06T16:44:34.000Z","size":127,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-16T16:51:26.883Z","etag":null,"topics":["rails","rails-api","rails-gem","ruby","ruby-on-rails"],"latest_commit_sha":null,"homepage":"","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/okirmis.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-03-08T13:21:47.000Z","updated_at":"2025-03-06T16:44:38.000Z","dependencies_parsed_at":"2024-05-01T18:04:59.558Z","dependency_job_id":null,"html_url":"https://github.com/okirmis/rails-param-validation","commit_stats":{"total_commits":67,"total_committers":3,"mean_commits":"22.333333333333332","dds":"0.16417910447761197","last_synced_commit":"0327bd1414042ea4a07d2c4985d61aab1e302a90"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/okirmis%2Frails-param-validation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/okirmis%2Frails-param-validation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/okirmis%2Frails-param-validation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/okirmis%2Frails-param-validation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/okirmis","download_url":"https://codeload.github.com/okirmis/rails-param-validation/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244156496,"owners_count":20407521,"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":["rails","rails-api","rails-gem","ruby","ruby-on-rails"],"created_at":"2024-10-08T23:05:52.066Z","updated_at":"2025-03-18T04:30:45.159Z","avatar_url":"https://github.com/okirmis.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# RailsParamValidation\n\nThis gem provides parameter validation for Rails using a declarative parameter definition and makes the automatic validation of complex parameters very easy. It also supports an export of the definition as an OpenAPI document.\n\n* [Why this gem?](./docs/main-idea.md)\n* [Getting started](./docs/getting-started.md)\n* [Annotations](./docs/annotations.md)\n* [How to specify types](./docs/type-definition.md)\n* [OpenAPI Export](./docs/openapi.md)\n\n## Quick Example\n\nLet's take a look at a very simple example: a controller with a sample action, which gets a list of floats, rounds them to the nearest integer and returns it in a json encoded form.\n\n```ruby\nclass ExampleController\n  desc \"Show the functionality of this gem\"\n\n  action \"Round float values\" do\n    # Expect a parameter with the name \"values\" which contains an array of floats\n    query_param :values, ArrayType(Float), \"Values to round\"\n    # Document the response of http status 200, which is an array of integers\n    response 200, :success, ArrayType(Integer), \"Rounded values response\"\n  end\n  def sample_action\n    render json: params[:values].map(\u0026:round)\n  end\n\n  # We assume GET /round to be mapped to this action\nend\n```\n\nSending a valid request, the parameters are validated and casted correctly and we get the response one would expect:\n\n```\n$ curl -H \"Accept: application/json\" \"http://localhost:3000/round?values[]=1.5\u0026values[]=2.0\u0026values[]=-0.777\"\n[2,2,-1]\n```\n\nWhen a request with invalid parameters is sent, we get an error response which also describes the error.\n\n```\n$ curl -H \"Accept: application/json\" \"http://localhost:3000/round?values[]=1.5\u0026values[]=2.0\u0026values[]=XYZ\"\n{\"status\":\"fail\",\"errors\":[{\"path\":\"values/2\",\"message\":\"Expected a float\"}]}\n```\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'rails-param-validation'\n```\n\nAnd then execute:\n\n    $ bundle install\n\nOr install it yourself as:\n\n    $ gem install rails-param-validator\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fokirmis%2Frails-param-validation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fokirmis%2Frails-param-validation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fokirmis%2Frails-param-validation/lists"}