{"id":13878938,"url":"https://github.com/andersondias/attributes_sanitizer","last_synced_at":"2025-10-31T14:30:38.544Z","repository":{"id":33545395,"uuid":"159212057","full_name":"andersondias/attributes_sanitizer","owner":"andersondias","description":"A simple way to append sanitizers to attributes to Rails 5+ applications.","archived":false,"fork":false,"pushed_at":"2023-03-08T19:58:07.000Z","size":94,"stargazers_count":23,"open_issues_count":10,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-29T09:22:33.426Z","etag":null,"topics":["gem","gems","rails","rails-plugins","ruby","ruby-on-rails","rubygems"],"latest_commit_sha":null,"homepage":null,"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/andersondias.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"MIT-LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2018-11-26T18:08:05.000Z","updated_at":"2023-04-22T03:44:12.000Z","dependencies_parsed_at":"2024-01-13T20:56:20.661Z","dependency_job_id":"f3126c40-5a13-4211-9950-8f3bb1778eb4","html_url":"https://github.com/andersondias/attributes_sanitizer","commit_stats":{"total_commits":42,"total_committers":3,"mean_commits":14.0,"dds":"0.16666666666666663","last_synced_commit":"74397e7bc85209c3d7ffb93cb4d004147a0d4d93"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andersondias%2Fattributes_sanitizer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andersondias%2Fattributes_sanitizer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andersondias%2Fattributes_sanitizer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andersondias%2Fattributes_sanitizer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/andersondias","download_url":"https://codeload.github.com/andersondias/attributes_sanitizer/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238828991,"owners_count":19537711,"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":["gem","gems","rails","rails-plugins","ruby","ruby-on-rails","rubygems"],"created_at":"2024-08-06T08:02:04.758Z","updated_at":"2025-10-31T14:30:38.314Z","avatar_url":"https://github.com/andersondias.png","language":"Ruby","funding_links":[],"categories":["Ruby"],"sub_categories":[],"readme":"[![Maintainability](https://api.codeclimate.com/v1/badges/29a55c3bd2dd9e5ed117/maintainability)](https://codeclimate.com/github/andersondias/attributes_sanitizer/maintainability) [![Test Coverage](https://api.codeclimate.com/v1/badges/29a55c3bd2dd9e5ed117/test_coverage)](https://codeclimate.com/github/andersondias/attributes_sanitizer/test_coverage) [![Build](https://travis-ci.org/andersondias/attributes_sanitizer.svg?branch=master)](https://travis-ci.org/andersondias/attributes_sanitizer.svg?branch=master)\n\n# AttributesSanitizer\n\nA simple way to append sanitizers to attributes on Rails.\n\n\n## Usage\n\n```ruby\nclass Product \u003c ApplicationRecord\n  sanitize_attribute :title, with: -\u003e (value) {\n    value.gsub(/[1-9]/, 'X')\n  }\n\n  sanitize_attributes :title, :description, with: [:downcase, :strip_tags]\nend\n```\n\nIt comes with pre-defined sanitizers:\n- `:stringify` which perform a `to_s` into the value, to be sanitized as a string. Can be used before other sanitizer, that depends to the value be a string\n- `:downcase` which downcases a given attribute string\n- `:upcase` which upcases a given attribute string\n- `:strip_tags` which removes any tags from the given string based on Rails sanitize helper.\n- `:strip_emojis` which removes any emoji from the given string\n- `:strip_spaces` which removes any white spaces from the beginning and end of given attribute\n\nYou might define your own sanitizers:\n\n```ruby\n# config/initializers/attribute_sanitizers.rb\n\nAttributesSanitizer.define_sanitizer :reverse do |value|\n  value.to_s.reverse\nend\n```\n\nIt also comes with predefined bundles:\n```ruby\nclass Product \u003c ApplicationRecord\n  sanitize_attribute :title, with: -\u003e (value) {\n    value.gsub(/[1-9]/, 'X')\n  }\n\n  sanitize_attributes :title, :description, with: :no_tags_emojis_or_extra_spaces\n  # same as: `with: %i(stringify strip_tags strip_emojis strip_spaces)\nend\n```\n\nAnd, finally, you are able to define your own bundles:\n```ruby\n# config/initializers/attribute_sanitizers.rb\nAttributesSanitizer.define_bundle(:my_bundle, %i(downcase strip_spaces))\n```\n\n## Installation\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'attributes_sanitizer'\n```\n\nAnd then execute:\n```bash\n$ bundle\n```\n\nOr install it yourself as:\n```bash\n$ gem install attributes_sanitizer\n```\n\n## License\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandersondias%2Fattributes_sanitizer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandersondias%2Fattributes_sanitizer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandersondias%2Fattributes_sanitizer/lists"}