{"id":18656791,"url":"https://github.com/zendesk/input_sanitizer","last_synced_at":"2025-04-11T18:31:21.719Z","repository":{"id":3363691,"uuid":"4409731","full_name":"zendesk/input_sanitizer","owner":"zendesk","description":"A gem to sanitize hash of incoming data","archived":false,"fork":false,"pushed_at":"2023-04-13T06:38:19.000Z","size":232,"stargazers_count":14,"open_issues_count":4,"forks_count":7,"subscribers_count":89,"default_branch":"master","last_synced_at":"2025-03-25T16:55:30.600Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zendesk.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG","contributing":null,"funding":null,"license":"LICENSE","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":"2012-05-22T16:52:53.000Z","updated_at":"2023-06-14T22:34:48.000Z","dependencies_parsed_at":"2024-11-07T07:41:42.450Z","dependency_job_id":null,"html_url":"https://github.com/zendesk/input_sanitizer","commit_stats":null,"previous_names":[],"tags_count":62,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zendesk%2Finput_sanitizer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zendesk%2Finput_sanitizer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zendesk%2Finput_sanitizer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zendesk%2Finput_sanitizer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zendesk","download_url":"https://codeload.github.com/zendesk/input_sanitizer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248458453,"owners_count":21107080,"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-11-07T07:25:20.130Z","updated_at":"2025-04-11T18:31:21.342Z","avatar_url":"https://github.com/zendesk.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# InputSanitizer\n![CI](https://github.com/zendesk/input_sanitizer/workflows/CI/badge.svg)\n\nGem to sanitize hash of incoming data\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n    gem 'input_sanitizer'\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install input_sanitizer\n\n## Usage\n\n```ruby\nclass PersonSanitizer \u003c InputSanitizer::Sanitizer\n  string :name\n  string :address\n  integer :height\n  float :ratio\n  date :birthday\nend\n\n# filters unwanted parameters\nsanitizer = PersonSanitizer.new({:account_id =\u003e 1, :name =\u003e \"John\"})\nsanitizer.cleaned() # =\u003e {:name =\u003e \"John\"}\n\n# provides key access\nsanitizer[:name] # =\u003e \"John\"\n\n# also provides shortcut method, same as new({}).cleaned\nPersonSanitizer.clean({:account_id =\u003e 1})\n\n# supports inheritance\nclass PrivilegedSanitizer \u003c PersonSanitizer\n  integer :account_id\nend\n\nPrivilegedSanitizer.clean({:account_id =\u003e 1})\n# =\u003e {:account_id =\u003e 1}\n\n# handles type conversions\nPrivilegedSanitizer.clean({:account_id =\u003e '1'})\n# =\u003e {:account_id =\u003e 1}\n\nPrivilegedSanitizer.clean({:birthday =\u003e '1986-10-06'})\n# =\u003e {:birthday =\u003e Date.new(1986, 10, 6)}\n\n# it prevents obvious errors\ndata = PrivilegedSanitizer.clean({:account_id =\u003e 3})\ndata[:account] # instead of :account_id\n# =\u003e InputSanitizer::KeyNotAllowedError: Key not allowed: account\n\n# supports custom value converters\nclass SomethingSanitizer \u003c InputSanitizer::Sanitizer\n  custom :backward, :converter =\u003e lambda { |v| v.reverse }\n  integer :version\n  custom :name, :provide =\u003e :version, :converter =\u003e lambda { |name, version|\n    version \u003c 3 ? name.downcase : name\n  }\nend\n```\n\n\n## Contributing\n\n1. Fork it\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Added some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create new Pull Request\n\n## Releasing new version of gem\n\n1. Update version [lib/input_sanitizer/version.rb](lib/input_sanitizer/version.rb) and push to `master`\n2. Create new GitHub release with tag name starting with `v` and the version, for example `v0.3.0`\n3. Gem will be automatically built and pushed to rubygems.org with GitHub Action\n\n## Copyright and license\n\nCopyright 2012 Zendesk\n\nLicensed under the [Apache License, Version 2.0](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzendesk%2Finput_sanitizer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzendesk%2Finput_sanitizer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzendesk%2Finput_sanitizer/lists"}